3 namespace Drupal\Core\Cache;
6 * Defines an interface for responses that can expose cacheability metadata.
8 * @see \Drupal\Core\Cache\CacheableResponseTrait
10 interface CacheableResponseInterface {
13 * Adds a dependency on an object: merges its cacheability metadata.
15 * For instance, when a response depends on some configuration, an entity, or
16 * an access result, we must make sure their cacheability metadata is present
17 * on the response. This method makes doing that simple.
19 * @param \Drupal\Core\Cache\CacheableDependencyInterface|mixed $dependency
20 * The dependency. If the object implements CacheableDependencyInterface,
21 * then its cacheability metadata will be used. Otherwise, the passed in
22 * object must be assumed to be uncacheable, so max-age 0 is set.
26 * @see \Drupal\Core\Cache\CacheableMetadata::createFromObject()
28 public function addCacheableDependency($dependency);
31 * Returns the cacheability metadata for this response.
33 * @return \Drupal\Core\Cache\CacheableMetadata
35 public function getCacheableMetadata();