function CacheableResponseTrait::addCacheableDependency
Same name in other branches
- 8.9.x core/lib/Drupal/Core/Cache/CacheableResponseTrait.php \Drupal\Core\Cache\CacheableResponseTrait::addCacheableDependency()
- 10 core/lib/Drupal/Core/Cache/CacheableResponseTrait.php \Drupal\Core\Cache\CacheableResponseTrait::addCacheableDependency()
- 11.x core/lib/Drupal/Core/Cache/CacheableResponseTrait.php \Drupal\Core\Cache\CacheableResponseTrait::addCacheableDependency()
1 call to CacheableResponseTrait::addCacheableDependency()
- HtmlResponse::setContent in core/
lib/ Drupal/ Core/ Render/ HtmlResponse.php - Sets the response content.
File
-
core/
lib/ Drupal/ Core/ Cache/ CacheableResponseTrait.php, line 22
Class
- CacheableResponseTrait
- Provides an implementation of CacheableResponseInterface.
Namespace
Drupal\Core\CacheCode
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.