function LanguageConfigFactoryOverride::onConfigRename

Same name in other branches
  1. 8.9.x core/modules/language/src/Config/LanguageConfigFactoryOverride.php \Drupal\language\Config\LanguageConfigFactoryOverride::onConfigRename()
  2. 10 core/modules/language/src/Config/LanguageConfigFactoryOverride.php \Drupal\language\Config\LanguageConfigFactoryOverride::onConfigRename()
  3. 11.x core/modules/language/src/Config/LanguageConfigFactoryOverride.php \Drupal\language\Config\LanguageConfigFactoryOverride::onConfigRename()

Overrides ConfigFactoryOverrideBase::onConfigRename

File

core/modules/language/src/Config/LanguageConfigFactoryOverride.php, line 189

Class

LanguageConfigFactoryOverride
Provides language overrides for the configuration factory.

Namespace

Drupal\language\Config

Code

public function onConfigRename(ConfigRenameEvent $event) {
    $config = $event->getConfig();
    $name = $config->getName();
    $old_name = $event->getOldName();
    foreach (\Drupal::languageManager()->getLanguages() as $language) {
        $config_translation = $this->getOverride($language->getId(), $old_name);
        if (!$config_translation->isNew()) {
            $saved_config = $config_translation->get();
            $storage = $this->getStorage($language->getId());
            $storage->write($name, $saved_config);
            $config_translation->delete();
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.