class ConfigCacheTag in Real Name 8
Same name and namespace in other branches
- 2.x src/EventSubscriber/ConfigCacheTag.php \Drupal\realname\EventSubscriber\ConfigCacheTag
A subscriber invalidating cache tags when realname config objects are saved.
Hierarchy
- class \Drupal\realname\EventSubscriber\ConfigCacheTag implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of ConfigCacheTag
1 string reference to 'ConfigCacheTag'
1 service uses ConfigCacheTag
File
- src/
EventSubscriber/ ConfigCacheTag.php, line 13
Namespace
Drupal\realname\EventSubscriberView source
class ConfigCacheTag implements EventSubscriberInterface {
/**
* The cache tags invalidator.
*
* @var \Drupal\Core\Cache\CacheTagsInvalidatorInterface
*/
protected $cacheTagsInvalidator;
/**
* Constructs a RealnameCacheTag object.
*
* @param \Drupal\Core\Cache\CacheTagsInvalidatorInterface $cache_tags_invalidator
* The cache tags invalidator.
*/
public function __construct(CacheTagsInvalidatorInterface $cache_tags_invalidator) {
$this->cacheTagsInvalidator = $cache_tags_invalidator;
}
/**
* Invalidate cache tags when particular realname config objects are saved.
*
* @param \Drupal\Core\Config\ConfigCrudEvent $event
* The Event to process.
*/
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',
]);
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[ConfigEvents::SAVE][] = [
'onSave',
];
return $events;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigCacheTag:: |
protected | property | The cache tags invalidator. | |
ConfigCacheTag:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
ConfigCacheTag:: |
public | function | Invalidate cache tags when particular realname config objects are saved. | |
ConfigCacheTag:: |
public | function | Constructs a RealnameCacheTag object. |