function EventSubscriber::onConfigSave
Same name in other branches
- 8.9.x core/modules/config/tests/config_import_test/src/EventSubscriber.php \Drupal\config_import_test\EventSubscriber::onConfigSave()
- 10 core/modules/config/tests/config_import_test/src/EventSubscriber.php \Drupal\config_import_test\EventSubscriber::onConfigSave()
- 11.x 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: The event.
File
-
core/
modules/ config/ tests/ config_import_test/ src/ EventSubscriber.php, line 89
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);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.