CacheableMetadata::setCacheMaxAge

public CacheableMetadata::setCacheMaxAge($max_age) Sets the maximum age (in seconds). Defaults to Cache::PERMANENT Parameters int $max_age: The max age to associate. Return value $this Throws \InvalidArgumentException If a non-integer value is supplied. File core/lib/Drupal/Core/Cache/CacheableMetadata.php, line 74 Class CacheableMetadata Defines a generic class for passing cacheability metadata. Namespace Drupal\Core\Cache Code public function setCacheMaxAge($max_age) { if (!is_i

CacheableMetadata::setCacheContexts

public CacheableMetadata::setCacheContexts(array $cache_contexts) Sets cache contexts. Parameters string[] $cache_contexts: The cache contexts to be associated. Return value $this File core/lib/Drupal/Core/Cache/CacheableMetadata.php, line 49 Class CacheableMetadata Defines a generic class for passing cacheability metadata. Namespace Drupal\Core\Cache Code public function setCacheContexts(array $cache_contexts) { $this->cacheContexts = $cache_contexts; return $this; }

CacheableMetadata::createFromRenderArray

public static CacheableMetadata::createFromRenderArray(array $build) Creates a CacheableMetadata object with values taken from a render array. Parameters array $build: A render array. Return value static File core/lib/Drupal/Core/Cache/CacheableMetadata.php, line 149 Class CacheableMetadata Defines a generic class for passing cacheability metadata. Namespace Drupal\Core\Cache Code public static function createFromRenderArray(array $build) { $meta = new static(); $meta->cacheCo

CacheableMetadata::applyTo

public CacheableMetadata::applyTo(array &$build) Applies the values of this CacheableMetadata object to a render array. Parameters array &$build: A render array. File core/lib/Drupal/Core/Cache/CacheableMetadata.php, line 135 Class CacheableMetadata Defines a generic class for passing cacheability metadata. Namespace Drupal\Core\Cache Code public function applyTo(array &$build) { $build['#cache']['contexts'] = $this->cacheContexts; $build['#cache']['tags'] = $this-&

CacheableMetadata::getCacheContexts

public CacheableMetadata::getCacheContexts() The cache contexts associated with this object. These identify a specific variation/representation of the object. Cache contexts are tokens: placeholders that are converted to cache keys by the @cache_contexts_manager service. The replacement value depends on the request context (the current URL, language, and so on). They're converted before storing an object in cache. Return value string[] An array of cache context tokens, used to generate a cache

CacheableMetadata::getCacheTags

public CacheableMetadata::getCacheTags() The cache tags associated with this object. When this object is modified, these cache tags will be invalidated. Return value string[] A set of cache tags. Overrides RefinableCacheableDependencyTrait::getCacheTags File core/lib/Drupal/Core/Cache/CacheableMetadata.php, line 17 Class CacheableMetadata Defines a generic class for passing cacheability metadata. Namespace Drupal\Core\Cache Code public function getCacheTags() { return $this->cach

CacheableMetadata::createFromObject

public static CacheableMetadata::createFromObject($object) Creates a CacheableMetadata object from a depended object. Parameters \Drupal\Core\Cache\CacheableDependencyInterface|mixed $object: The object whose cacheability metadata to retrieve. If it implements CacheableDependencyInterface, its cacheability metadata will be used, otherwise, the passed in object must be assumed to be uncacheable, so max-age 0 is set. Return value static File core/lib/Drupal/Core/Cache/CacheableMetadata.php, lin

CacheableMetadata::getCacheMaxAge

public CacheableMetadata::getCacheMaxAge() The maximum age for which this object may be cached. Return value int The maximum time in seconds that this object may be cached. Overrides RefinableCacheableDependencyTrait::getCacheMaxAge File core/lib/Drupal/Core/Cache/CacheableMetadata.php, line 57 Class CacheableMetadata Defines a generic class for passing cacheability metadata. Namespace Drupal\Core\Cache Code public function getCacheMaxAge() { return $this->cacheMaxAge; }

CacheableDependencyInterface::getCacheMaxAge

public CacheableDependencyInterface::getCacheMaxAge() The maximum age for which this object may be cached. Return value int The maximum time in seconds that this object may be cached. File core/lib/Drupal/Core/Cache/CacheableDependencyInterface.php, line 50 Class CacheableDependencyInterface Defines an interface for objects which may be used by other cached objects. Namespace Drupal\Core\Cache Code public function getCacheMaxAge();

CacheableMetadata

Defines a generic class for passing cacheability metadata. Hierarchy class \Drupal\Core\Cache\CacheableMetadata implements RefinableCacheableDependencyInterface uses RefinableCacheableDependencyTrait Related topics Cache API Information about the Drupal Cache API File core/lib/Drupal/Core/Cache/CacheableMetadata.php, line 10 Namespace Drupal\Core\Cache Members Name Modifiers Type Description CacheableMetadata::applyTo public function Applies the values of this Cacheabl