You are here

class ParagraphsCollectionStyleConfigCacheTag in Paragraphs Collection 8

Invalidates the 'rendered' cache tag when saving paragraphs_collection.settings.

Hierarchy

Expanded class hierarchy of ParagraphsCollectionStyleConfigCacheTag

1 string reference to 'ParagraphsCollectionStyleConfigCacheTag'
paragraphs_collection.services.yml in ./paragraphs_collection.services.yml
paragraphs_collection.services.yml
1 service uses ParagraphsCollectionStyleConfigCacheTag
paragraphs_collection.style_config_cache_tag_invalidator in ./paragraphs_collection.services.yml
Drupal\paragraphs_collection\EventSubscriber\ParagraphsCollectionStyleConfigCacheTag

File

src/EventSubscriber/ParagraphsCollectionStyleConfigCacheTag.php, line 14

Namespace

Drupal\paragraphs_collection\EventSubscriber
View source
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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ParagraphsCollectionStyleConfigCacheTag::$cacheTagsInvalidator protected property The cache tags invalidator.
ParagraphsCollectionStyleConfigCacheTag::getSubscribedEvents public static function
ParagraphsCollectionStyleConfigCacheTag::onSave public function Invalidate the 'rendered' cache tag whenever the settings are modified.
ParagraphsCollectionStyleConfigCacheTag::__construct public function Constructs a ParagraphsCollectionSettingsCacheTag object.