W3cubDocs

/Drupal 8

public function ConfigFactory::onConfigSave

public ConfigFactory::onConfigSave(ConfigCrudEvent $event)

Updates stale static cache entries when configuration is saved.

Parameters

ConfigCrudEvent $event: The configuration event.

File

core/lib/Drupal/Core/Config/ConfigFactory.php, line 337

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());
    }
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Config!ConfigFactory.php/function/ConfigFactory::onConfigSave/8.1.x