You are here

public function ConfigCacheTag::onSave in Real Name 8

Same name and namespace in other branches
  1. 2.x src/EventSubscriber/ConfigCacheTag.php \Drupal\realname\EventSubscriber\ConfigCacheTag::onSave()

Invalidate cache tags when particular realname config objects are saved.

Parameters

\Drupal\Core\Config\ConfigCrudEvent $event: The Event to process.

File

src/EventSubscriber/ConfigCacheTag.php, line 38

Class

ConfigCacheTag
A subscriber invalidating cache tags when realname config objects are saved.

Namespace

Drupal\realname\EventSubscriber

Code

public function onSave(ConfigCrudEvent $event) {

  // Check if realname settings object has been changed.
  if ($event
    ->getConfig()
    ->getName() === 'realname.settings') {

    // Clear the realname cache if the pattern was changed.
    realname_delete_all();

    // A change to the display-name pattern must invalidate the render cache
    // since the display-name could be used anywhere.
    $this->cacheTagsInvalidator
      ->invalidateTags([
      'rendered',
    ]);
  }
}