trait CacheableResponseTrait in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Cache/CacheableResponseTrait.php \Drupal\Core\Cache\CacheableResponseTrait
Provides an implementation of CacheableResponseInterface.
Hierarchy
- trait \Drupal\Core\Cache\CacheableResponseTrait
See also
\Drupal\Core\Cache\CacheableResponseInterface
4 files declare their use of CacheableResponseTrait
- CacheableSecuredRedirectResponse.php in core/
lib/ Drupal/ Core/ Routing/ CacheableSecuredRedirectResponse.php - Contains \Drupal\Core\Routing\CacheableSecuredRedirectResponse.
- CacheableTestResponse.php in core/
modules/ system/ tests/ modules/ early_rendering_controller_test/ src/ CacheableTestResponse.php - Contains \Drupal\early_rendering_controller_test\CacheableTestResponse.
- HtmlResponse.php in core/
lib/ Drupal/ Core/ Render/ HtmlResponse.php - Contains \Drupal\Core\Render\HtmlResponse.
- ResourceResponse.php in core/
modules/ rest/ src/ ResourceResponse.php - Contains \Drupal\rest\ResourceResponse.
File
- core/
lib/ Drupal/ Core/ Cache/ CacheableResponseTrait.php, line 15 - Contains \Drupal\Core\Cache\CacheableResponseTrait.
Namespace
Drupal\Core\CacheView source
trait CacheableResponseTrait {
/**
* The cacheability metadata.
*
* @var \Drupal\Core\Cache\CacheableMetadata
*/
protected $cacheabilityMetadata;
/**
* {@inheritdoc}
*/
public function addCacheableDependency($dependency) {
// A trait doesn't have a constructor, so initialize the cacheability
// metadata if that hasn't happened yet.
if (!isset($this->cacheabilityMetadata)) {
$this->cacheabilityMetadata = new CacheableMetadata();
}
$this->cacheabilityMetadata = $this->cacheabilityMetadata
->merge(CacheableMetadata::createFromObject($dependency));
return $this;
}
/**
* {@inheritdoc}
*/
public function getCacheableMetadata() {
// A trait doesn't have a constructor, so initialize the cacheability
// metadata if that hasn't happened yet.
if (!isset($this->cacheabilityMetadata)) {
$this->cacheabilityMetadata = new CacheableMetadata();
}
return $this->cacheabilityMetadata;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CacheableResponseTrait:: |
protected | property | The cacheability metadata. | |
CacheableResponseTrait:: |
public | function | ||
CacheableResponseTrait:: |
public | function |