Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ContextAwarePluginTrait.php

function ContextAwarePluginTrait::getCacheContexts

14 calls to ContextAwarePluginTrait::getCacheContexts()
CurrentThemeCondition::getCacheContexts in core/modules/system/src/Plugin/Condition/CurrentThemeCondition.php
CurrentThemeCondition::getCacheContexts in core/modules/system/src/Plugin/Condition/CurrentThemeCondition.php
HelpBlock::getCacheContexts in core/modules/help/src/Plugin/Block/HelpBlock.php
HelpBlock::getCacheContexts in core/modules/help/src/Plugin/Block/HelpBlock.php
RequestPath::getCacheContexts in core/modules/system/src/Plugin/Condition/RequestPath.php

... See full list

7 methods override ContextAwarePluginTrait::getCacheContexts()
CurrentThemeCondition::getCacheContexts in core/modules/system/src/Plugin/Condition/CurrentThemeCondition.php
HelpBlock::getCacheContexts in core/modules/help/src/Plugin/Block/HelpBlock.php
RequestPath::getCacheContexts in core/modules/system/src/Plugin/Condition/RequestPath.php
ResponseStatus::getCacheContexts in core/modules/system/src/Plugin/Condition/ResponseStatus.php
SystemMenuBlock::getCacheContexts in core/modules/system/src/Plugin/Block/SystemMenuBlock.php

... See full list

File

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

Class

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

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

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal