You are here

public function LanguageConfigFactoryOverride::onConfigRename in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/language/src/Config/LanguageConfigFactoryOverride.php \Drupal\language\Config\LanguageConfigFactoryOverride::onConfigRename()

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 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();
    }
  }
}