Locale Config helper
$config is always a DrupalConfig object.
Expanded class hierarchy of LocaleConfigSubscriber
class LocaleConfigSubscriber implements EventSubscriberInterface {
/**
* Override configuration values with localized data.
*
* @param Drupal\Core\Config\ConfigEvent $event
* The Event to process.
*/
public function configLoad(ConfigEvent $event) {
$config = $event
->getConfig();
$language = language(LANGUAGE_TYPE_INTERFACE);
$locale_name = $this
->getLocaleConfigName($config
->getName(), $language);
if ($override = $config
->getStorage()
->read($locale_name)) {
$config
->setOverride($override);
}
}
/**
* Get configuration name for this language.
*
* It will be the same name with a prefix depending on language code:
* locale.config.LANGCODE.NAME
*/
public function getLocaleConfigName($name, $language) {
return 'locale.config.' . $language->langcode . '.' . $name;
}
/**
* Implements EventSubscriberInterface::getSubscribedEvents().
*/
static function getSubscribedEvents() {
$events['config.load'][] = array(
'configLoad',
20,
);
return $events;
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LocaleConfigSubscriber:: |
public | function | Override configuration values with localized data. | |
LocaleConfigSubscriber:: |
public | function | Get configuration name for this language. | |
LocaleConfigSubscriber:: |
static | function |
Implements EventSubscriberInterface::getSubscribedEvents(). Overrides EventSubscriberInterface:: |