RefinableCacheableDependencyTrait.php in Drupal 8
File
core/lib/Drupal/Core/Cache/RefinableCacheableDependencyTrait.php
View source
<?php
namespace Drupal\Core\Cache;
trait RefinableCacheableDependencyTrait {
use CacheableDependencyTrait;
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 {
$this->cacheMaxAge = 0;
}
return $this;
}
public function addCacheContexts(array $cache_contexts) {
if ($cache_contexts) {
$this->cacheContexts = Cache::mergeContexts($this->cacheContexts, $cache_contexts);
}
return $this;
}
public function addCacheTags(array $cache_tags) {
if ($cache_tags) {
$this->cacheTags = Cache::mergeTags($this->cacheTags, $cache_tags);
}
return $this;
}
public function mergeCacheMaxAge($max_age) {
$this->cacheMaxAge = Cache::mergeMaxAges($this->cacheMaxAge, $max_age);
return $this;
}
}