function RefinableCacheableDependencyTrait::addCacheContexts

Same name in other branches
  1. 9 core/lib/Drupal/Core/Cache/RefinableCacheableDependencyTrait.php \Drupal\Core\Cache\RefinableCacheableDependencyTrait::addCacheContexts()
  2. 10 core/lib/Drupal/Core/Cache/RefinableCacheableDependencyTrait.php \Drupal\Core\Cache\RefinableCacheableDependencyTrait::addCacheContexts()
  3. 11.x core/lib/Drupal/Core/Cache/RefinableCacheableDependencyTrait.php \Drupal\Core\Cache\RefinableCacheableDependencyTrait::addCacheContexts()
4 calls to RefinableCacheableDependencyTrait::addCacheContexts()
AccessResult::cachePerPermissions in core/lib/Drupal/Core/Access/AccessResult.php
Convenience method, adds the "user.permissions" cache context.
AccessResult::cachePerUser in core/lib/Drupal/Core/Access/AccessResult.php
Convenience method, adds the "user" cache context.
HelpSearch::findResults in core/modules/help_topics/src/Plugin/Search/HelpSearch.php
Finds the search results.
RefinableCacheableDependencyTrait::addCacheableDependency in core/lib/Drupal/Core/Cache/RefinableCacheableDependencyTrait.php

File

core/lib/Drupal/Core/Cache/RefinableCacheableDependencyTrait.php, line 31

Class

RefinableCacheableDependencyTrait
Trait for \Drupal\Core\Cache\RefinableCacheableDependencyInterface.

Namespace

Drupal\Core\Cache

Code

public function addCacheContexts(array $cache_contexts) {
    if ($cache_contexts) {
        $this->cacheContexts = Cache::mergeContexts($this->cacheContexts, $cache_contexts);
    }
    return $this;
}

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