You are here

public function RedirectSettingsCacheTag::onSave in Url Redirect 8

Same name and namespace in other branches
  1. 8.2 src/EventSubscriber/RedirectSettingsCacheTag.php \Drupal\url_redirect\EventSubscriber\RedirectSettingsCacheTag::onSave()

Invalidate the 'rendered' cache tag whenever the settings are modified.

Parameters

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

File

src/EventSubscriber/RedirectSettingsCacheTag.php, line 38

Class

RedirectSettingsCacheTag
A subscriber invalidating the 'rendered' cache tag when saving redirect settings.

Namespace

Drupal\url_redirect\EventSubscriber

Code

public function onSave(ConfigCrudEvent $event) {

  // Changing the Redirect settings means that any cached page might
  // result in a different response, so we need to invalidate them all.
  $id = $event
    ->getConfig()
    ->get('id');
  if ($event
    ->getConfig()
    ->getName() === "url_redirect.url_redirect.{$id}") {
    $this->cacheTagsInvalidator
      ->invalidateTags([
      'rendered',
    ]);
  }
}