trait CacheableDependencyTrait in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Cache/CacheableDependencyTrait.php \Drupal\Core\Cache\CacheableDependencyTrait
- 10 core/lib/Drupal/Core/Cache/CacheableDependencyTrait.php \Drupal\Core\Cache\CacheableDependencyTrait
Trait for \Drupal\Core\Cache\CacheableDependencyInterface.
Hierarchy
- trait \Drupal\Core\Cache\CacheableDependencyTrait
21 files declare their use of CacheableDependencyTrait
- Broken.php in core/
lib/ Drupal/ Core/ Block/ Plugin/ Block/ Broken.php - CacheableAccessDeniedHttpException.php in core/
lib/ Drupal/ Core/ Http/ Exception/ CacheableAccessDeniedHttpException.php - CacheableBadRequestHttpException.php in core/
lib/ Drupal/ Core/ Http/ Exception/ CacheableBadRequestHttpException.php - CacheableConflictHttpException.php in core/
lib/ Drupal/ Core/ Http/ Exception/ CacheableConflictHttpException.php - CacheableGoneHttpException.php in core/
lib/ Drupal/ Core/ Http/ Exception/ CacheableGoneHttpException.php
File
- core/
lib/ Drupal/ Core/ Cache/ CacheableDependencyTrait.php, line 8
Namespace
Drupal\Core\CacheView source
trait CacheableDependencyTrait {
/**
* Cache contexts.
*
* @var string[]
*/
protected $cacheContexts = [];
/**
* Cache tags.
*
* @var string[]
*/
protected $cacheTags = [];
/**
* Cache max-age.
*
* @var int
*/
protected $cacheMaxAge = Cache::PERMANENT;
/**
* Sets cacheability; useful for value object constructors.
*
* @param \Drupal\Core\Cache\CacheableDependencyInterface $cacheability
* The cacheability to set.
*
* @return $this
*/
protected function setCacheability(CacheableDependencyInterface $cacheability) {
$this->cacheContexts = $cacheability
->getCacheContexts();
$this->cacheTags = $cacheability
->getCacheTags();
$this->cacheMaxAge = $cacheability
->getCacheMaxAge();
return $this;
}
/**
* {@inheritdoc}
*/
public function getCacheTags() {
return $this->cacheTags;
}
/**
* {@inheritdoc}
*/
public function getCacheContexts() {
return $this->cacheContexts;
}
/**
* {@inheritdoc}
*/
public function getCacheMaxAge() {
return $this->cacheMaxAge;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CacheableDependencyTrait:: |
protected | property | Cache contexts. | |
CacheableDependencyTrait:: |
protected | property | Cache max-age. | |
CacheableDependencyTrait:: |
protected | property | Cache tags. | |
CacheableDependencyTrait:: |
public | function | 3 | |
CacheableDependencyTrait:: |
public | function | 3 | |
CacheableDependencyTrait:: |
public | function | 3 | |
CacheableDependencyTrait:: |
protected | function | Sets cacheability; useful for value object constructors. |