Namespace
Drupal\subpathauto\EventSubscriber
File
-
src/EventSubscriber/ConfigCacheInvalidator.php
View source
<?php
namespace Drupal\subpathauto\EventSubscriber;
use Drupal\Core\Cache\CacheTagsInvalidatorInterface;
use Drupal\Core\Config\ConfigCrudEvent;
use Drupal\Core\Config\ConfigEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class ConfigCacheInvalidator implements EventSubscriberInterface {
protected $cacheTagsInvalidator;
public function __construct(CacheTagsInvalidatorInterface $cache_tags_invalidator) {
$this->cacheTagsInvalidator = $cache_tags_invalidator;
}
public function onSave(ConfigCrudEvent $event) {
if ($event->getConfig()
->getName() === 'subpathauto.settings') {
$this->cacheTagsInvalidator
->invalidateTags([
'rendered',
]);
}
}
public static function getSubscribedEvents() {
$events[ConfigEvents::SAVE][] = [
'onSave',
];
return $events;
}
}
Classes
| Title |
Deprecated |
Summary |
| ConfigCacheInvalidator |
|
A subscriber invalidating cache tags when subpathauto config is saved. |