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::merge

public CacheableMetadata::merge(CacheableMetadata $other) Merges the values of another CacheableMetadata object with this one. Parameters \Drupal\Core\Cache\CacheableMetadata $other: The other CacheableMetadata object. Return value static A new CacheableMetadata object, with the merged data. File core/lib/Drupal/Core/Cache/CacheableMetadata.php, line 92 Class CacheableMetadata Defines a generic class for passing cacheability metadata. Namespace Drupal\Core\Cache Code public function

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::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; }

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::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::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::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

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

CacheableDependencyInterface::getCacheTags

public CacheableDependencyInterface::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. File core/lib/Drupal/Core/Cache/CacheableDependencyInterface.php, line 42 Class CacheableDependencyInterface Defines an interface for objects which may be used by other cached objects. Namespace Drupal\Core\Cache Code public function getCacheTags();