public function EventSubscriber::onConfigSave in Drupal 8
Same name and namespace in other branches
- 9 core/modules/config/tests/config_import_test/src/EventSubscriber.php \Drupal\config_import_test\EventSubscriber::onConfigSave()
Reacts to a config save and records information in state for testing.
Parameters
\Drupal\Core\Config\ConfigCrudEvent $event:
File
- core/
modules/ config/ tests/ config_import_test/ src/ EventSubscriber.php, line 88
Class
- EventSubscriber
- Config import subscriber for config import events.
Namespace
Drupal\config_import_testCode
public function onConfigSave(ConfigCrudEvent $event) {
$config = $event
->getConfig();
if ($config
->getName() == 'automated_cron.settings') {
$values = $this->state
->get('ConfigImportUITest.automated_cron.settings.interval', []);
$values[] = $config
->get('interval');
$this->state
->set('ConfigImportUITest.automated_cron.settings.interval', $values);
}
if ($config
->getName() == 'core.extension') {
$installed = $this->state
->get('ConfigImportUITest.core.extension.modules_installed', []);
$uninstalled = $this->state
->get('ConfigImportUITest.core.extension.modules_uninstalled', []);
$original = $config
->getOriginal('module');
$data = $config
->get('module');
$install = array_diff_key($data, $original);
if (!empty($install)) {
$installed[] = key($install);
}
$uninstall = array_diff_key($original, $data);
if (!empty($uninstall)) {
$uninstalled[] = key($uninstall);
}
$this->state
->set('ConfigImportUITest.core.extension.modules_installed', $installed);
$this->state
->set('ConfigImportUITest.core.extension.modules_uninstalled', $uninstalled);
}
}