You are here

public function ContextAwarePluginTrait::getCacheTags in Drupal 9

4 calls to ContextAwarePluginTrait::getCacheTags()
AggregatorFeedBlock::getCacheTags in core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php
ForumBlockBase::getCacheTags in core/modules/forum/src/Plugin/Block/ForumBlockBase.php
SystemBrandingBlock::getCacheTags in core/modules/system/src/Plugin/Block/SystemBrandingBlock.php
SystemMenuBlock::getCacheTags in core/modules/system/src/Plugin/Block/SystemMenuBlock.php
4 methods override ContextAwarePluginTrait::getCacheTags()
AggregatorFeedBlock::getCacheTags in core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php
ForumBlockBase::getCacheTags in core/modules/forum/src/Plugin/Block/ForumBlockBase.php
SystemBrandingBlock::getCacheTags in core/modules/system/src/Plugin/Block/SystemBrandingBlock.php
SystemMenuBlock::getCacheTags in core/modules/system/src/Plugin/Block/SystemMenuBlock.php

File

core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php, line 221

Class

ContextAwarePluginTrait
Provides a trait to add context-aware functionality to plugins.

Namespace

Drupal\Core\Plugin

Code

public function getCacheTags() {
  $tags = [];

  // Applied contexts can affect the cache tags when this plugin is
  // involved in caching, collect and return them.
  foreach ($this
    ->getContexts() as $context) {

    /** @var \Drupal\Core\Cache\CacheableDependencyInterface $context */
    if ($context instanceof CacheableDependencyInterface) {
      $tags = Cache::mergeTags($tags, $context
        ->getCacheTags());
    }
  }
  return $tags;
}