3 namespace Drupal\Core\Cache;
6 * Allows to add cacheability metadata to an object for the current runtime.
8 * This must be used when changing an object in a way that affects its
9 * cacheability. For example, when changing the active translation of an entity
10 * based on the current content language then a cache context for that must be
13 interface RefinableCacheableDependencyInterface extends CacheableDependencyInterface {
16 * Adds cache contexts.
18 * @param string[] $cache_contexts
19 * The cache contexts to be added.
23 public function addCacheContexts(array $cache_contexts);
28 * @param string[] $cache_tags
29 * The cache tags to be added.
33 public function addCacheTags(array $cache_tags);
36 * Merges the maximum age (in seconds) with the existing maximum age.
38 * The max age will be set to the given value if it is lower than the existing
42 * The max age to associate.
46 * @throws \InvalidArgumentException
47 * Thrown if a non-integer value is supplied.
49 public function mergeCacheMaxAge($max_age);
52 * Adds a dependency on an object: merges its cacheability metadata.
54 * @param \Drupal\Core\Cache\CacheableDependencyInterface|object $other_object
55 * The dependency. If the object implements CacheableDependencyInterface,
56 * then its cacheability metadata will be used. Otherwise, the passed in
57 * object must be assumed to be uncacheable, so max-age 0 is set.
61 * @see \Drupal\Core\Cache\CacheableMetadata::createFromObject()
63 public function addCacheableDependency($other_object);