LanguageConfigFactoryOverride::onConfigRename

public LanguageConfigFactoryOverride::onConfigRename(ConfigRenameEvent $event)

Actions to be performed to configuration override on configuration rename.

Parameters

\Drupal\Core\Config\ConfigRenameEvent $event: The config rename event.

Overrides ConfigFactoryOverrideBase::onConfigRename

File

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

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();
    }
  }
}
doc_Drupal
2016-10-29 09:22:08
Comments
Leave a Comment

Please login to continue.