private function ConfigImportEventSubscriber::saveConfigFromState in Config Ignore Keys 8
Fetches the state variable defined by key/file and saves it.
Parameters
string $configFile: The config file name.
string $configKey: The configuration key which needs to be ignored.
1 call to ConfigImportEventSubscriber::saveConfigFromState()
- ConfigImportEventSubscriber::onConfigImport in src/
EventSubscriber/ ConfigImportEventSubscriber.php - Saves the old configuration for the ignored config keys.
File
- src/
EventSubscriber/ ConfigImportEventSubscriber.php, line 174
Class
- ConfigImportEventSubscriber
- Class ConfigImportEventSubscriber.
Namespace
Drupal\config_ignore_keys\EventSubscriberCode
private function saveConfigFromState($configFile, $configKey) {
foreach ($this->languageManager
->getLanguages() as $language) {
$stateValue = $stateValue = $this->state
->get($language
->getId() . $configFile . $configKey);
if (isset($stateValue)) {
$config_translation = $this->languageConfigFactoryOverride
->getOverride($language
->getId(), $configFile);
$config_translation
->set($configKey, $stateValue);
$config_translation
->save();
}
}
$stateValue = $this->state
->get($configFile . $configKey);
if (isset($stateValue)) {
$config = $this->configFactory
->getEditable($configFile);
if (!empty($config)) {
$config
->set($configKey, $stateValue);
$config
->save();
}
}
}