mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/RevisionSlider
synced 2024-11-23 23:13:29 +00:00
Do not use the main config for extension configuration options
This currently just works, because the currently used backend are global variables. Once the main config uses a more scoped/focused backend, such as a HashConfig or a database-based config, requesting extension configurations from it will not work anymore. Therefore, use the extensions Config object to request configuration options for the extension. Change-Id: Iea02d3c284f9a0e12abff33e3624dce9585ab51c
This commit is contained in:
parent
c7be55dbc5
commit
5173fe59d4
|
@ -18,6 +18,9 @@
|
|||
"requires": {
|
||||
"MediaWiki": ">= 1.25.0"
|
||||
},
|
||||
"ConfigRegistry": {
|
||||
"revisionslider": "GlobalVarConfig::newInstance"
|
||||
},
|
||||
"config": {
|
||||
"@RevisionSliderBetaFeature": "Make the RevisionSlider feature a BetaFeature. Setting this requires the RevisionSlider extension and requires each user to enable the BetaFeature.",
|
||||
"RevisionSliderBetaFeature": false,
|
||||
|
|
|
@ -10,12 +10,31 @@ use MediaWiki\MediaWikiServices;
|
|||
*/
|
||||
class RevisionSliderHooks {
|
||||
|
||||
/**
|
||||
* @var Config
|
||||
*/
|
||||
private static $config;
|
||||
|
||||
/**
|
||||
* Returns the RevisionSlider extensions config.
|
||||
*
|
||||
* @return Config
|
||||
*/
|
||||
private static function getConfig() {
|
||||
if ( self::$config === null ) {
|
||||
self::$config = MediaWikiServices::getInstance()
|
||||
->getConfigFactory()
|
||||
->makeConfig( 'revisionslider' );
|
||||
}
|
||||
return self::$config;
|
||||
}
|
||||
|
||||
public static function onDiffViewHeader(
|
||||
DifferenceEngine $diff,
|
||||
Revision $oldRev,
|
||||
Revision $newRev
|
||||
) {
|
||||
$config = MediaWikiServices::getInstance()->getMainConfig();
|
||||
$config = self::getConfig();
|
||||
|
||||
/**
|
||||
* If this extension is configured to be a beta feature, and the BetaFeatures extension
|
||||
|
@ -112,7 +131,7 @@ class RevisionSliderHooks {
|
|||
}
|
||||
|
||||
public static function getBetaFeaturePreferences( User $user, array &$prefs ) {
|
||||
$config = MediaWikiServices::getInstance()->getMainConfig();
|
||||
$config = self::getConfig();
|
||||
$extensionAssetsPath = $config->get( 'ExtensionAssetsPath' );
|
||||
|
||||
if ( $config->get( 'RevisionSliderBetaFeature' ) ) {
|
||||
|
|
Loading…
Reference in a new issue