You are here

private function ConfigImportEventSubscriber::saveStateWithConfig in Config Ignore Keys 8

Fetches the key data from the file and saves it into state.

Parameters

string $configFile: The config file name.

string $configKey: The configuration key which needs to be ignored.

1 call to ConfigImportEventSubscriber::saveStateWithConfig()
ConfigImportEventSubscriber::onConfigValidate in src/EventSubscriber/ConfigImportEventSubscriber.php
Reacts to configuration validation.

File

src/EventSubscriber/ConfigImportEventSubscriber.php, line 149

Class

ConfigImportEventSubscriber
Class ConfigImportEventSubscriber.

Namespace

Drupal\config_ignore_keys\EventSubscriber

Code

private function saveStateWithConfig($configFile, $configKey) {
  $config = $this->configFactory
    ->getEditable($configFile);
  foreach ($this->languageManager
    ->getLanguages() as $language) {
    $config_translation = $this->languageConfigFactoryOverride
      ->getOverride($language
      ->getId(), $configFile);
    if (!$config_translation
      ->isNew()) {
      $data = $config_translation
        ->get($configKey);
      if (isset($data)) {
        $this->state
          ->set($language
          ->getId() . $configFile . $configKey, $data);
      }
    }
  }
  if (!empty($config) && NULL !== ($config = $config
    ->get($configKey))) {
    $this->state
      ->set($configFile . $configKey, $config);
  }
}