You are here

public function ContextAwarePluginBase::getCacheContexts in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Plugin/ContextAwarePluginBase.php \Drupal\Core\Plugin\ContextAwarePluginBase::getCacheContexts()
8 calls to ContextAwarePluginBase::getCacheContexts()
BookNavigationBlock::getCacheContexts in core/modules/book/src/Plugin/Block/BookNavigationBlock.php
CurrentThemeCondition::getCacheContexts in core/modules/system/src/Plugin/Condition/CurrentThemeCondition.php
ForumBlockBase::getCacheContexts in core/modules/forum/src/Plugin/Block/ForumBlockBase.php
HelpBlock::getCacheContexts in core/modules/help/src/Plugin/Block/HelpBlock.php
LocalActionsBlock::getCacheContexts in core/lib/Drupal/Core/Menu/Plugin/Block/LocalActionsBlock.php

... See full list

9 methods override ContextAwarePluginBase::getCacheContexts()
BookNavigationBlock::getCacheContexts in core/modules/book/src/Plugin/Block/BookNavigationBlock.php
CurrentThemeCondition::getCacheContexts in core/modules/system/src/Plugin/Condition/CurrentThemeCondition.php
ForumBlockBase::getCacheContexts in core/modules/forum/src/Plugin/Block/ForumBlockBase.php
HelpBlock::getCacheContexts in core/modules/help/src/Plugin/Block/HelpBlock.php
LocalActionsBlock::getCacheContexts in core/lib/Drupal/Core/Menu/Plugin/Block/LocalActionsBlock.php

... See full list

File

core/lib/Drupal/Core/Plugin/ContextAwarePluginBase.php, line 135
Contains \Drupal\Core\Plugin\ContextAwarePluginBase.

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;
}