ParagraphsCollectionStyleConfigCacheTag.php in Paragraphs Collection 8
File
src/EventSubscriber/ParagraphsCollectionStyleConfigCacheTag.phpView source
<?php
namespace Drupal\paragraphs_collection\EventSubscriber;
use Drupal\Core\Cache\CacheTagsInvalidatorInterface;
use Drupal\Core\Config\ConfigCrudEvent;
use Drupal\Core\Config\ConfigEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Invalidates the 'rendered' cache tag when saving
* paragraphs_collection.settings.
*/
class ParagraphsCollectionStyleConfigCacheTag implements EventSubscriberInterface {
/**
* The cache tags invalidator.
*
* @var \Drupal\Core\Cache\CacheTagsInvalidatorInterface
*/
protected $cacheTagsInvalidator;
/**
* Constructs a ParagraphsCollectionSettingsCacheTag 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 the 'rendered' cache tag whenever the settings are modified.
*
* @param \Drupal\Core\Config\ConfigCrudEvent $event
* The Event to process.
*/
public function onSave(ConfigCrudEvent $event) {
if ($event
->getConfig()
->getName() === 'paragraphs_collection.settings') {
// Invalidate caches.
$this->cacheTagsInvalidator
->invalidateTags([
'rendered',
]);
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[ConfigEvents::SAVE][] = [
'onSave',
];
return $events;
}
}
Classes
Name | Description |
---|---|
ParagraphsCollectionStyleConfigCacheTag | Invalidates the 'rendered' cache tag when saving paragraphs_collection.settings. |