You are here

public function RefinableCacheableDependencyTrait::addCacheableDependency in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Cache/RefinableCacheableDependencyTrait.php \Drupal\Core\Cache\RefinableCacheableDependencyTrait::addCacheableDependency()
6 calls to RefinableCacheableDependencyTrait::addCacheableDependency()
AccessResult::cacheUntilConfigurationChanges in core/lib/Drupal/Core/Access/AccessResult.php
Convenience method, adds the configuration object's cache tag.
AccessResult::cacheUntilEntityChanges in core/lib/Drupal/Core/Access/AccessResult.php
Convenience method, adds the entity's cache tag.
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
NodeSearch::prepareResults in core/modules/node/src/Plugin/Search/NodeSearch.php
Prepares search results for rendering.

... 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 60
Contains \Drupal\Core\Cache\RefinableCacheableDependencyTrait.

Class

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

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