You are here

public function ConfigFactory::onConfigSave in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Config/ConfigFactory.php \Drupal\Core\Config\ConfigFactory::onConfigSave()

Updates stale static cache entries when configuration is saved.

Parameters

ConfigCrudEvent $event: The configuration event.

File

core/lib/Drupal/Core/Config/ConfigFactory.php, line 342
Contains \Drupal\Core\Config\ConfigFactory.

Class

ConfigFactory
Defines the configuration object factory.

Namespace

Drupal\Core\Config

Code

public function onConfigSave(ConfigCrudEvent $event) {

  // Ensure that the static cache contains up to date configuration objects by
  // replacing the data on any entries for the configuration object apart
  // from the one that references the actual config object being saved.
  $saved_config = $event
    ->getConfig();
  foreach ($this
    ->getConfigCacheKeys($saved_config
    ->getName()) as $cache_key) {
    $cached_config = $this->cache[$cache_key];
    if ($cached_config !== $saved_config) {

      // We can not just update the data since other things about the object
      // might have changed. For example, whether or not it is new.
      $this->cache[$cache_key]
        ->initWithData($saved_config
        ->getRawData());
    }
  }
}