You are here

public function EventSubscriber::onConfigSave in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 93
Contains \Drupal\config_import_test\EventSubscriber.

Class

EventSubscriber
Config import subscriber for config import events.

Namespace

Drupal\config_import_test

Code

public function onConfigSave(ConfigCrudEvent $event) {
  $config = $event
    ->getConfig();
  if ($config
    ->getName() == 'action.settings') {
    $values = $this->state
      ->get('ConfigImportUITest.action.settings.recursion_limit', array());
    $values[] = $config
      ->get('recursion_limit');
    $this->state
      ->set('ConfigImportUITest.action.settings.recursion_limit', $values);
  }
  if ($config
    ->getName() == 'core.extension') {
    $installed = $this->state
      ->get('ConfigImportUITest.core.extension.modules_installed', array());
    $uninstalled = $this->state
      ->get('ConfigImportUITest.core.extension.modules_uninstalled', array());
    $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);
  }
}