-
Download and move Lakat extension files to
extensions/Lakatdirectory in your MediaWiki installation. -
Add the following code at the bottom of your
LocalSettings.phpfile:wfLoadExtension( 'Lakat' );
-
Run the update script which will automatically create necessary database tables that this extension needs.
php maintenance/run.php update -
Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
SQL files to create necessary tables can be found in sql/ subdirectory. Run update script when database schema update is necessary.
Access permissions are defined in extension.json, e.g.:
"AvailableRights": [
"lakat-createbranch"
],
"GroupPermissions": {
"user": {
"lakat-createbranch": true
}
},See Manual:$wgAvailableRights for details.
Permissions defined in this way can be used in special pages by providing it in the constructor:
parent::__construct( 'CreateBranch', 'lakat-createbranch' );Additionally, special page can require user log in. Method SpecialPage::requireNamedUser() can be used to conveniently show log in form.
Dependency injection in MediaWiki is implemented in service container class MediaWikiServices. It is responsible for creation of all service classes, including those from extensions.
To find out what services are defined in Lakat extension look at following files:
- ServiceWiring.php - defines how services are created by mapping service names to instantiation callbacks
- LakatServices.php - defines static functions for easy access to service, e.g.
LakatServices::getStagingService()
Constructor parameter is the recommended best practice to inject service in your class and should be used instead of direct instantiation when possible, e.g.:
class SomeClass {
private StagingService $stagingService;
public function __construct( StagingService $stagingService ) {
$this->stagingService = $stagingService;
}
public function someMethod() {
$this->stagingService->getStagedArticles( 'SomeBranch' );
}
}StagingService controls what articles are currently modified relatively to the last submit to Lakat storage.
Internally service keeps track of modified articles in SQL table lakat_staging.
StagingService is registered in MediaWiki's service container and should be instantiated like it is shown above.
getStagedArticles- retrieve list of modified articlesstage- add articles to the list of modified articlesunstage- remove article from the list of modified articlessubmitStaged- submit selected articles to Lakatreset- reset modified article to the state stored in Lakat storage- if article doesn't exist on Lakat then delete wiki page
- otherwise fetch article content from Lakat and save as new revision in wiki page, then unstage article
SpecialFetchBranch is a redirect special page which is special kind of special page in MediaWiki. When requesting URL SpecialFetchBranch/<BranchId> then branch is fetched from Lakat and stored in wiki page.