trait CacheableDependencyTrait in JSON:API 8
Trait for \Drupal\Core\Cache\CacheableDependencyInterface.
@internal
Hierarchy
- trait \Drupal\jsonapi\Normalizer\CacheableDependencyTrait
Deprecated
Remove when JSON API requires Drupal 8.5 or newer, update all users to \Drupal\Core\Cache\CacheableDependencyTrait instead.
4 files declare their use of CacheableDependencyTrait
- EntityNormalizerValue.php in src/
Normalizer/ Value/ EntityNormalizerValue.php - FieldItemNormalizerValue.php in src/
Normalizer/ Value/ FieldItemNormalizerValue.php - FieldNormalizerValue.php in src/
Normalizer/ Value/ FieldNormalizerValue.php - NullFieldNormalizerValue.php in src/
Normalizer/ Value/ NullFieldNormalizerValue.php
File
- src/
Normalizer/ CacheableDependencyTrait.php, line 14
Namespace
Drupal\jsonapi\NormalizerView 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 | ||
CacheableDependencyTrait:: |
public | function | ||
CacheableDependencyTrait:: |
public | function | ||
CacheableDependencyTrait:: |
protected | function | Sets cacheability; useful for value object constructors. |