function ContextAwarePluginBase::getCacheTags

Overrides CacheableDependencyInterface::getCacheTags

File

core/lib/Drupal/Core/Plugin/ContextAwarePluginBase.php, line 146

Class

ContextAwarePluginBase
Base class for plugins that are context aware.

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 $context \Drupal\Core\Cache\CacheableDependencyInterface */
        if ($context instanceof CacheableDependencyInterface) {
            $tags = Cache::mergeTags($tags, $context->getCacheTags());
        }
    }
    return $tags;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.