annotate core/lib/Drupal/Core/Cache/CacheableResponseInterface.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 4c8ae668cc8c
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\Core\Cache;
Chris@0 4
Chris@0 5 /**
Chris@0 6 * Defines an interface for responses that can expose cacheability metadata.
Chris@0 7 *
Chris@0 8 * @see \Drupal\Core\Cache\CacheableResponseTrait
Chris@0 9 */
Chris@0 10 interface CacheableResponseInterface {
Chris@0 11
Chris@0 12 /**
Chris@0 13 * Adds a dependency on an object: merges its cacheability metadata.
Chris@0 14 *
Chris@0 15 * For instance, when a response depends on some configuration, an entity, or
Chris@0 16 * an access result, we must make sure their cacheability metadata is present
Chris@0 17 * on the response. This method makes doing that simple.
Chris@0 18 *
Chris@0 19 * @param \Drupal\Core\Cache\CacheableDependencyInterface|mixed $dependency
Chris@0 20 * The dependency. If the object implements CacheableDependencyInterface,
Chris@0 21 * then its cacheability metadata will be used. Otherwise, the passed in
Chris@0 22 * object must be assumed to be uncacheable, so max-age 0 is set.
Chris@0 23 *
Chris@0 24 * @return $this
Chris@0 25 *
Chris@0 26 * @see \Drupal\Core\Cache\CacheableMetadata::createFromObject()
Chris@0 27 */
Chris@0 28 public function addCacheableDependency($dependency);
Chris@0 29
Chris@0 30 /**
Chris@0 31 * Returns the cacheability metadata for this response.
Chris@0 32 *
Chris@0 33 * @return \Drupal\Core\Cache\CacheableMetadata
Chris@0 34 */
Chris@0 35 public function getCacheableMetadata();
Chris@0 36
Chris@0 37 }