class ConfigEventsSubscriber in Breadcrumb Manager 8
Class ConfigEventsSubscriber.
@package Drupal\breadcrumb_manager_context\EventSubscriber
Hierarchy
- class \Drupal\breadcrumb_manager_context\EventSubscriber\ConfigEventsSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of ConfigEventsSubscriber
1 string reference to 'ConfigEventsSubscriber'
- breadcrumb_manager_context.services.yml in modules/
breadcrumb_manager_context/ breadcrumb_manager_context.services.yml - modules/breadcrumb_manager_context/breadcrumb_manager_context.services.yml
1 service uses ConfigEventsSubscriber
- my_config_events_subscriber in modules/
breadcrumb_manager_context/ breadcrumb_manager_context.services.yml - \Drupal\breadcrumb_manager_context\EventSubscriber\ConfigEventsSubscriber
File
- modules/
breadcrumb_manager_context/ src/ EventSubscriber/ ConfigEventsSubscriber.php, line 15
Namespace
Drupal\breadcrumb_manager_context\EventSubscriberView source
class ConfigEventsSubscriber implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
return [
ConfigEvents::SAVE => 'invalidateContextCacheTags',
ConfigEvents::DELETE => 'invalidateContextCacheTags',
];
}
/**
* React to a config object being saved.
*
* @param \Drupal\Core\Config\ConfigCrudEvent $event
* Config crud event.
*/
public function invalidateContextCacheTags(ConfigCrudEvent $event) {
$config = $event
->getConfig();
// Only act on Context config entities.
if (!preg_match('/^context\\.context\\./', $config
->getName())) {
return;
}
// Invalidate cache tags only if we've updated a context which uses the
// breadcrumb reaction.
$context = $config
->getRawData();
if (isset($context['reactions']['breadcrumb'])) {
Cache::invalidateTags([
'breadcrumb_manager',
'breadcrumb_manager_context',
]);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigEventsSubscriber:: |
public static | function | ||
ConfigEventsSubscriber:: |
public | function | React to a config object being saved. |