3 namespace Drupal\Core\Cache;
6 * Trait for \Drupal\Core\Cache\CacheableDependencyInterface.
8 trait CacheableDependencyTrait {
15 protected $cacheContexts = [];
22 protected $cacheTags = [];
29 protected $cacheMaxAge = Cache::PERMANENT;
32 * Sets cacheability; useful for value object constructors.
34 * @param \Drupal\Core\Cache\CacheableDependencyInterface $cacheability
35 * The cacheability to set.
39 protected function setCacheability(CacheableDependencyInterface $cacheability) {
40 $this->cacheContexts = $cacheability->getCacheContexts();
41 $this->cacheTags = $cacheability->getCacheTags();
42 $this->cacheMaxAge = $cacheability->getCacheMaxAge();
49 public function getCacheTags() {
50 return $this->cacheTags;
56 public function getCacheContexts() {
57 return $this->cacheContexts;
63 public function getCacheMaxAge() {
64 return $this->cacheMaxAge;