mwstake / mediawiki-component-manifestregistry
Provides classes and services to interact with registries in MediaWiki manifests
Installs: 20 766
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 8
Forks: 1
Open Issues: 0
Requires
Requires (Dev)
- jakub-onderka/php-console-highlighter: 0.4.0
- jakub-onderka/php-parallel-lint: 1.0.0
- mediawiki/mediawiki-codesniffer: 29.0.0
- mediawiki/minus-x: 1.0.0
This package is auto-updated.
Last update: 2024-11-11 08:37:03 UTC
README
ManifestRegistry for MediaWiki
Provides a combined registry over all in the attribute
section registered things in extension.json
files.
This code is meant to be executed within the MediaWiki application context. No standalone usage is intended.
Use in a MediaWiki extension
Add "mwstake/mediawiki-component-manifestregistry": "~2.0"
to the require
section of your composer.json
file.
Since 2.0 explicit initialization is required. This can be achieved by
- either adding
"callback": "mwsInitComponents"
to yourextension.json
/skin.json
- or calling
mwsInitComponents();
within you extensions/skins customcallback
method
See also mwstake/mediawiki-componentloader
.
Register values in extension.json
{ "attributes": { "BlueSpiceFoundation": { "RoleRegistry": { "admin": "\\BlueSpice\\Permission\\Role\\Admin::factory", "editor": "\\BlueSpice\\Permission\\Role\\Editor::factory", "reader": "\\BlueSpice\\Permission\\Role\\Reader::factory", "author": "\\BlueSpice\\Permission\\Role\\Author::factory", "reviewer": "\\BlueSpice\\Permission\\Role\\Reviewer::factory", "accountmanager": "\\BlueSpice\\Permission\\Role\\AccountManager::factory" } }, "BlueSpicePrivacy": { "CookieConsentNativeMWCookies": { "notificationFlag": { "group": "necessary", "addPrefix": true } } } }, "manifest_version": 2, }
Implement in your code
$factory = \MediaWiki\MediaWikiServices::getInstance()->getService( 'MWStakeManifestRegistryFactory' ); $registry = $factory->get( 'MyExtensionMyRegistry' ); $myValues = $registry->getValue( 'subValue' ); $allMyValues = $registry->getAllValues();
Configuration
mwsgManifestRegistryOverrides
: Used to overwrite existing registries by either add, remove or merge their values:
Example 1:
$GLOBALS['mwsgManifestRegistryOverrides']['MyRegistry'] = [ 'set' => [ 'ReplaceKey' => 'with new value', ], 'merge' => [ 'AddThisKey' => 'with this value', ], 'remove' => [ 'keyOfValueThatShouldBeRemoved' ] ]