function ContextAwarePluginBase::getCacheContexts

4 calls to ContextAwarePluginBase::getCacheContexts()
BookNavigationBlock::getCacheContexts in core/modules/book/src/Plugin/Block/BookNavigationBlock.php
BookNavigationBlock::getCacheContexts in core/modules/book/src/Plugin/Block/BookNavigationBlock.php
BookNavigationBlock::getCacheContexts in core/modules/book/src/Plugin/Block/BookNavigationBlock.php
BookNavigationBlock::getCacheContexts in core/modules/book/src/Plugin/Block/BookNavigationBlock.php
6 methods override ContextAwarePluginBase::getCacheContexts()
CurrentThemeCondition::getCacheContexts in core/modules/system/src/Plugin/Condition/CurrentThemeCondition.php
The cache contexts associated with this object.
ForumBlockBase::getCacheContexts in core/modules/forum/src/Plugin/Block/ForumBlockBase.php
The cache contexts associated with this object.
HelpBlock::getCacheContexts in core/modules/help/src/Plugin/Block/HelpBlock.php
The cache contexts associated with this object.
RequestPath::getCacheContexts in core/modules/system/src/Plugin/Condition/RequestPath.php
The cache contexts associated with this object.
SystemMenuBlock::getCacheContexts in core/modules/system/src/Plugin/Block/SystemMenuBlock.php
The cache contexts associated with this object.

... See full list

File

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

Class

ContextAwarePluginBase
Base class for plugins that are context aware.

Namespace

Drupal\Core\Plugin

Code

public function getCacheContexts() {
  $cache_contexts = [];
  // Applied contexts can affect the cache contexts 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) {
      $cache_contexts = Cache::mergeContexts($cache_contexts, $context->getCacheContexts());
    }
  }
  return $cache_contexts;
}

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