core/lib/Drupal/Core/Cache/CacheableMetadata.php | 5 ++++- core/lib/Drupal/Core/Cache/CacheableResponseInterface.php | 6 +++++- core/lib/Drupal/Core/Render/RendererInterface.php | 6 +++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/core/lib/Drupal/Core/Cache/CacheableMetadata.php b/core/lib/Drupal/Core/Cache/CacheableMetadata.php index d21bd65..0a22f56 100644 --- a/core/lib/Drupal/Core/Cache/CacheableMetadata.php +++ b/core/lib/Drupal/Core/Cache/CacheableMetadata.php @@ -178,7 +178,10 @@ public static function createFromRenderArray(array $build) { * Creates a CacheableMetadata object from a depended object. * * @param \Drupal\Core\Cache\CacheableDependencyInterface|mixed $object - * The object whose cacheability metadata to retrieve. + * 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 static */ diff --git a/core/lib/Drupal/Core/Cache/CacheableResponseInterface.php b/core/lib/Drupal/Core/Cache/CacheableResponseInterface.php index 99db5fa..0bca8d1 100644 --- a/core/lib/Drupal/Core/Cache/CacheableResponseInterface.php +++ b/core/lib/Drupal/Core/Cache/CacheableResponseInterface.php @@ -22,9 +22,13 @@ * response. This method makes doing that simple. * * @param \Drupal\Core\Cache\CacheableDependencyInterface|mixed $dependency - * The dependency. + * The dependency. If the object implements CacheableDependencyInterface, + * then its cacheability metadata will be used. Otherwise, the passed in + * object must be assumed to be uncacheable, so max-age 0 is set. * * @return $this + * + * @see \Drupal\Core\Cache\CacheableMetadata::createFromObject() */ public function addCacheableDependency($dependency); diff --git a/core/lib/Drupal/Core/Render/RendererInterface.php b/core/lib/Drupal/Core/Render/RendererInterface.php index 9ffb34f..b004b70 100644 --- a/core/lib/Drupal/Core/Render/RendererInterface.php +++ b/core/lib/Drupal/Core/Render/RendererInterface.php @@ -353,7 +353,11 @@ public function mergeBubbleableMetadata(array $a, array $b); * @param array &$elements * The render array to update. * @param \Drupal\Core\Cache\CacheableDependencyInterface|mixed $dependency - * The dependency. + * The dependency. If the object implements CacheableDependencyInterface, + * then its cacheability metadata will be used. Otherwise, the passed in + * object must be assumed to be uncacheable, so max-age 0 is set. + * + * @see \Drupal\Core\Cache\CacheableMetadata::createFromObject() */ public function addCacheableDependency(array &$elements, $dependency);