Merge "Drop the Vector.Config service"
This commit is contained in:
commit
6fc95b72ba
|
@ -11,13 +11,13 @@ use FatalError;
|
|||
*/
|
||||
final class Constants {
|
||||
/**
|
||||
* This is tightly coupled to the ConfigRegistry field in skin.json.
|
||||
* This is tightly coupled to the ValidSkinNames field in skin.json.
|
||||
* @var string
|
||||
*/
|
||||
public const SKIN_NAME_MODERN = 'vector-2022';
|
||||
|
||||
/**
|
||||
* This is tightly coupled to the ConfigRegistry field in skin.json.
|
||||
* This is tightly coupled to the ValidSkinNames field in skin.json.
|
||||
* @var string
|
||||
*/
|
||||
public const SKIN_NAME_LEGACY = 'vector';
|
||||
|
@ -33,11 +33,6 @@ final class Constants {
|
|||
*/
|
||||
public const SKIN_VERSION_LATEST = '2';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const SERVICE_CONFIG = 'Vector.Config';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
|
|
@ -448,7 +448,8 @@ class Hooks {
|
|||
* @param bool $isAutoCreated
|
||||
*/
|
||||
public static function onLocalUserCreated( User $user, $isAutoCreated ) {
|
||||
$default = self::getConfig( Constants::CONFIG_KEY_DEFAULT_SKIN_VERSION_FOR_NEW_ACCOUNTS );
|
||||
$config = MediaWikiServices::getInstance()->getMainConfig();
|
||||
$default = $config->get( Constants::CONFIG_KEY_DEFAULT_SKIN_VERSION_FOR_NEW_ACCOUNTS );
|
||||
if ( $default ) {
|
||||
$optionsManager = MediaWikiServices::getInstance()->getUserOptionsManager();
|
||||
$optionsManager->setOption(
|
||||
|
@ -651,30 +652,12 @@ class Hooks {
|
|||
|
||||
if ( $user->isRegistered() && self::isSkinVersionLegacy( $skinName ) ) {
|
||||
$vars[ 'wgVectorDisableSidebarPersistence' ] =
|
||||
self::getConfig(
|
||||
$out->getConfig()->get(
|
||||
Constants::CONFIG_KEY_DISABLE_SIDEBAR_PERSISTENCE
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a configuration variable.
|
||||
*
|
||||
* @param string $name Name of configuration option.
|
||||
* @return mixed Value configured.
|
||||
* @throws \ConfigException
|
||||
*/
|
||||
private static function getConfig( $name ) {
|
||||
return self::getServiceConfig()->get( $name );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Config
|
||||
*/
|
||||
private static function getServiceConfig() {
|
||||
return MediaWikiServices::getInstance()->getService( Constants::SERVICE_CONFIG );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether the current skin version is the legacy version.
|
||||
* Should mirror SkinVector::isLegacy
|
||||
|
|
|
@ -29,9 +29,6 @@ use Vector\FeatureManagement\Requirements\DynamicConfigRequirement;
|
|||
use Vector\FeatureManagement\Requirements\OverridableConfigRequirement;
|
||||
|
||||
return [
|
||||
Constants::SERVICE_CONFIG => static function ( MediaWikiServices $services ) {
|
||||
return $services->getService( 'ConfigFactory' )->makeConfig( Constants::SKIN_NAME_LEGACY );
|
||||
},
|
||||
Constants::SERVICE_FEATURE_MANAGER => static function ( MediaWikiServices $services ) {
|
||||
$featureManager = new FeatureManager();
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ final class VectorServices {
|
|||
* Gets the feature manager service.
|
||||
*
|
||||
* Per its definition in ServiceWiring.php, the feature manager service is bound to the global
|
||||
* request and user objects and to the _Vector.Config_ service.
|
||||
* request and user objects.
|
||||
*
|
||||
* @return FeatureManager
|
||||
*/
|
||||
|
|
|
@ -128,9 +128,6 @@
|
|||
"AutoloadNamespaces": {
|
||||
"Vector\\": "includes/"
|
||||
},
|
||||
"ConfigRegistry": {
|
||||
"vector": "GlobalVarConfig::newInstance"
|
||||
},
|
||||
"Hooks": {
|
||||
"ResourceLoaderSiteModulePages": "Vector\\Hooks::onResourceLoaderSiteModulePages",
|
||||
"ResourceLoaderSiteStylesModulePages": "Vector\\Hooks::onResourceLoaderSiteStylesModulePages",
|
||||
|
|
|
@ -322,10 +322,9 @@ class VectorHooksTest extends MediaWikiIntegrationTestCase {
|
|||
* @covers ::onLocalUserCreated
|
||||
*/
|
||||
public function testOnLocalUserCreatedLegacy() {
|
||||
$config = new HashConfig( [
|
||||
'VectorDefaultSkinVersionForNewAccounts' => Constants::SKIN_VERSION_LEGACY,
|
||||
$this->setMwGlobals( [
|
||||
'wgVectorDefaultSkinVersionForNewAccounts' => Constants::SKIN_VERSION_LEGACY,
|
||||
] );
|
||||
$this->setService( 'Vector.Config', $config );
|
||||
|
||||
$user = $this->createMock( User::class );
|
||||
$userOptionsManager = $this->createMock( UserOptionsManager::class );
|
||||
|
@ -341,10 +340,9 @@ class VectorHooksTest extends MediaWikiIntegrationTestCase {
|
|||
* @covers ::onLocalUserCreated
|
||||
*/
|
||||
public function testOnLocalUserCreatedLatest() {
|
||||
$config = new HashConfig( [
|
||||
'VectorDefaultSkinVersionForNewAccounts' => Constants::SKIN_VERSION_LATEST,
|
||||
$this->setMwGlobals( [
|
||||
'wgVectorDefaultSkinVersionForNewAccounts' => Constants::SKIN_VERSION_LATEST,
|
||||
] );
|
||||
$this->setService( 'Vector.Config', $config );
|
||||
|
||||
$user = $this->createMock( User::class );
|
||||
$userOptionsManager = $this->createMock( UserOptionsManager::class );
|
||||
|
|
Loading…
Reference in New Issue