Add config for language in header for logged in/out users

Register updated requirement for language in header for logged in and logged out users in Vector's ServiceWiring file. Make VectorLanguageInHeader backwards compatible to handle boolean values when registering LanguageInHeader feature. Update VectorLanguageInHeader variable to array in config to handle different logged states.

Bug: T277588
Change-Id: I37a3a01e83f051cf0679769c8b9b5b41f00d6d72
This commit is contained in:
Clare Ming 2021-04-07 09:56:41 -06:00
parent ec6bca52ee
commit 8cab50874c
2 changed files with 24 additions and 8 deletions

View File

@ -69,12 +69,25 @@ return [
// Feature: Languages in sidebar
// ================================
$featureManager->registerRequirement(
new DynamicConfigRequirement(
$services->getMainConfig(),
Constants::CONFIG_KEY_LANGUAGE_IN_HEADER,
Constants::REQUIREMENT_LANGUAGE_IN_HEADER
)
$config = $services->getMainConfig();
$languageInHeaderConfig = $config->get( Constants::CONFIG_KEY_LANGUAGE_IN_HEADER );
// Backwards compatibility with config variables that have been set in production.
if ( is_bool( $languageInHeaderConfig ) ) {
$languageInHeaderConfig = [
'logged_in' => $languageInHeaderConfig,
'logged_out' => $languageInHeaderConfig,
];
} else {
$languageInHeaderConfig = [
'logged_in' => $languageInHeaderConfig['logged_in'] ?? false,
'logged_out' => $languageInHeaderConfig['logged_out'] ?? false,
];
}
$featureManager->registerSimpleRequirement(
Constants::REQUIREMENT_LANGUAGE_IN_HEADER,
$languageInHeaderConfig[ $context->getUser()->isRegistered() ? 'logged_in' : 'logged_out' ]
);
$featureManager->registerFeature(

View File

@ -271,8 +271,11 @@
"value": false
},
"VectorLanguageInHeader": {
"value": false,
"description": "@var boolean Moves the language links from the sidebar into a menu beside the page title. Also moves the indicators to the line below, next to the tagline (siteSub)."
"value": {
"logged_in": false,
"logged_out": false
},
"description": "@var array Moves the language links from the sidebar into a menu beside the page title. Also moves the indicators to the line below, next to the tagline (siteSub)."
},
"VectorDisableSidebarPersistence": {
"value": false,