function RefinableCacheableDependencyTrait::addCacheableDependency

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Cache/RefinableCacheableDependencyTrait.php \Drupal\Core\Cache\RefinableCacheableDependencyTrait::addCacheableDependency()
  2. 8.9.x core/lib/Drupal/Core/Cache/RefinableCacheableDependencyTrait.php \Drupal\Core\Cache\RefinableCacheableDependencyTrait::addCacheableDependency()
  3. 10 core/lib/Drupal/Core/Cache/RefinableCacheableDependencyTrait.php \Drupal\Core\Cache\RefinableCacheableDependencyTrait::addCacheableDependency()
6 calls to RefinableCacheableDependencyTrait::addCacheableDependency()
AccessResult::inheritCacheability in core/lib/Drupal/Core/Access/AccessResult.php
Inherits the cacheability of the other access result, if any.
BubbleableMetadata::addCacheableDependency in core/lib/Drupal/Core/Render/BubbleableMetadata.php
HelpSearch::prepareResults in core/modules/help/src/Plugin/Search/HelpSearch.php
Prepares search results for display.
NodeSearch::prepareResults in core/modules/node/src/Plugin/Search/NodeSearch.php
Prepares search results for rendering.
RefinableCalculatedPermissions::merge in core/lib/Drupal/Core/Session/RefinableCalculatedPermissions.php
Merge another calculated permissions object into this one.

... See full list

1 method overrides RefinableCacheableDependencyTrait::addCacheableDependency()
BubbleableMetadata::addCacheableDependency in core/lib/Drupal/Core/Render/BubbleableMetadata.php

File

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

Class

RefinableCacheableDependencyTrait
Trait for <a href="/api/drupal/core%21lib%21Drupal%21Core%21Cache%21RefinableCacheableDependencyInterface.php/interface/RefinableCacheableDependencyInterface/11.x" title="Allows to add cacheability metadata to an object for the current runtime." class="local">\Drupal\Core\Cache\RefinableCacheableDependencyInterface</a>.

Namespace

Drupal\Core\Cache

Code

public function addCacheableDependency($other_object) {
    if ($other_object instanceof CacheableDependencyInterface) {
        $this->addCacheContexts($other_object->getCacheContexts());
        $this->addCacheTags($other_object->getCacheTags());
        $this->mergeCacheMaxAge($other_object->getCacheMaxAge());
    }
    else {
        // Not a cacheable dependency, this can not be cached.
        $this->cacheMaxAge = 0;
    }
    return $this;
}

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