class ConfigSubscriber in Analytics 8
Analytics ConfigSubscriber.
Hierarchy
- class \Drupal\analytics\EventSubscriber\ConfigSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of ConfigSubscriber
1 string reference to 'ConfigSubscriber'
1 service uses ConfigSubscriber
File
- src/
EventSubscriber/ ConfigSubscriber.php, line 13
Namespace
Drupal\analytics\EventSubscriberView source
class ConfigSubscriber implements EventSubscriberInterface {
/**
* The cache tags invalidator.
*
* @var \Drupal\Core\Cache\CacheTagsInvalidatorInterface
*/
protected $cacheTagsInvalidator;
/**
* Constructs a new ConfigSubscriber.
*
* @param \Drupal\Core\Cache\CacheTagsInvalidatorInterface $cache_tags_invalidator
* The cache tags invalidator.
*/
public function __construct(CacheTagsInvalidatorInterface $cache_tags_invalidator) {
$this->cacheTagsInvalidator = $cache_tags_invalidator;
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
return [
ConfigEvents::SAVE => [
'onConfigSave',
],
];
}
/**
* Respond to the config save event.
*
* @param \Drupal\Core\Config\ConfigCrudEvent $event
* The Event to process.
*/
public function onConfigSave(ConfigCrudEvent $event) {
// Changing the Analytics settings means that any cached page might
// result in a different response, so we need to invalidate them all.
if ($event
->getConfig()
->getName() === 'analytics.settings') {
$this->cacheTagsInvalidator
->invalidateTags([
'rendered',
]);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigSubscriber:: |
protected | property | The cache tags invalidator. | |
ConfigSubscriber:: |
public static | function | ||
ConfigSubscriber:: |
public | function | Respond to the config save event. | |
ConfigSubscriber:: |
public | function | Constructs a new ConfigSubscriber. |