Mercurial > hg > isophonics-drupal-site
comparison core/lib/Drupal/Core/Cache/CacheableDependencyTrait.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Core\Cache; | |
4 | |
5 /** | |
6 * Trait for \Drupal\Core\Cache\CacheableDependencyInterface. | |
7 */ | |
8 trait CacheableDependencyTrait { | |
9 | |
10 /** | |
11 * Cache contexts. | |
12 * | |
13 * @var string[] | |
14 */ | |
15 protected $cacheContexts = []; | |
16 | |
17 /** | |
18 * Cache tags. | |
19 * | |
20 * @var string[] | |
21 */ | |
22 protected $cacheTags = []; | |
23 | |
24 /** | |
25 * Cache max-age. | |
26 * | |
27 * @var int | |
28 */ | |
29 protected $cacheMaxAge = Cache::PERMANENT; | |
30 | |
31 /** | |
32 * Sets cacheability; useful for value object constructors. | |
33 * | |
34 * @param \Drupal\Core\Cache\CacheableDependencyInterface $cacheability | |
35 * The cacheability to set. | |
36 * | |
37 * @return $this | |
38 */ | |
39 protected function setCacheability(CacheableDependencyInterface $cacheability) { | |
40 $this->cacheContexts = $cacheability->getCacheContexts(); | |
41 $this->cacheTags = $cacheability->getCacheTags(); | |
42 $this->cacheMaxAge = $cacheability->getCacheMaxAge(); | |
43 return $this; | |
44 } | |
45 | |
46 /** | |
47 * {@inheritdoc} | |
48 */ | |
49 public function getCacheTags() { | |
50 return $this->cacheTags; | |
51 } | |
52 | |
53 /** | |
54 * {@inheritdoc} | |
55 */ | |
56 public function getCacheContexts() { | |
57 return $this->cacheContexts; | |
58 } | |
59 | |
60 /** | |
61 * {@inheritdoc} | |
62 */ | |
63 public function getCacheMaxAge() { | |
64 return $this->cacheMaxAge; | |
65 } | |
66 | |
67 } |