function CacheableDependencyTrait::setCacheability

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Cache/CacheableDependencyTrait.php \Drupal\Core\Cache\CacheableDependencyTrait::setCacheability()
  2. 8.9.x core/lib/Drupal/Core/Cache/CacheableDependencyTrait.php \Drupal\Core\Cache\CacheableDependencyTrait::setCacheability()
  3. 10 core/lib/Drupal/Core/Cache/CacheableDependencyTrait.php \Drupal\Core\Cache\CacheableDependencyTrait::setCacheability()

Sets cacheability; useful for value object constructors.

Parameters

\Drupal\Core\Cache\CacheableDependencyInterface $cacheability: The cacheability to set.

Return value

$this

21 calls to CacheableDependencyTrait::setCacheability()
CacheableAccessDeniedHttpException::__construct in core/lib/Drupal/Core/Http/Exception/CacheableAccessDeniedHttpException.php
CacheableBadRequestHttpException::__construct in core/lib/Drupal/Core/Http/Exception/CacheableBadRequestHttpException.php
CacheableConflictHttpException::__construct in core/lib/Drupal/Core/Http/Exception/CacheableConflictHttpException.php
CacheableGoneHttpException::__construct in core/lib/Drupal/Core/Http/Exception/CacheableGoneHttpException.php
CacheableHttpException::__construct in core/lib/Drupal/Core/Http/Exception/CacheableHttpException.php

... See full list

File

core/lib/Drupal/Core/Cache/CacheableDependencyTrait.php, line 39

Class

CacheableDependencyTrait
Trait for <a href="/api/drupal/core%21lib%21Drupal%21Core%21Cache%21CacheableDependencyInterface.php/interface/CacheableDependencyInterface/11.x" title="Defines an interface for objects which may be used by other cached objects." class="local">\Drupal\Core\Cache\CacheableDependencyInterface</a>.

Namespace

Drupal\Core\Cache

Code

protected function setCacheability(CacheableDependencyInterface $cacheability) {
    $this->cacheContexts = $cacheability->getCacheContexts();
    $this->cacheTags = $cacheability->getCacheTags();
    $this->cacheMaxAge = $cacheability->getCacheMaxAge();
    return $this;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.