core/lib/Drupal/Core/Cache/CacheContexts.php | 2 +- core/lib/Drupal/Core/Cache/ConfigurableCacheContextInterface.php | 6 +++++- core/lib/Drupal/Core/Cache/ThemeCacheContext.php | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/lib/Drupal/Core/Cache/CacheContexts.php b/core/lib/Drupal/Core/Cache/CacheContexts.php index 3d4a446..19caae0 100644 --- a/core/lib/Drupal/Core/Cache/CacheContexts.php +++ b/core/lib/Drupal/Core/Cache/CacheContexts.php @@ -136,7 +136,7 @@ public function getCacheTagsForTokens(array $context_tokens) { throw new \InvalidArgumentException(String::format('"@context" is not a valid cache context ID.', ['@context' => $context_id])); } $service = $this->getService($context_id); - if (method_exists($service, 'getCacheTags')) { + if ($service instanceof ConfigurableCacheContextInterface) { $tags = Cache::mergeTags($service->getCacheTags($parameter)); } } diff --git a/core/lib/Drupal/Core/Cache/ConfigurableCacheContextInterface.php b/core/lib/Drupal/Core/Cache/ConfigurableCacheContextInterface.php index 877fe27..d26b65e 100644 --- a/core/lib/Drupal/Core/Cache/ConfigurableCacheContextInterface.php +++ b/core/lib/Drupal/Core/Cache/ConfigurableCacheContextInterface.php @@ -15,8 +15,12 @@ /** * The cache tags associated with the cache context. * + * @param string|null $parameter + * The parameter, in case of a calculated cache context. + * * @return string[] + * The assocaited cache tags. */ - public function getCacheTags(); + public function getCacheTags($parameter = NULL); } diff --git a/core/lib/Drupal/Core/Cache/ThemeCacheContext.php b/core/lib/Drupal/Core/Cache/ThemeCacheContext.php index 9620c70..ae3985c 100644 --- a/core/lib/Drupal/Core/Cache/ThemeCacheContext.php +++ b/core/lib/Drupal/Core/Cache/ThemeCacheContext.php @@ -13,7 +13,7 @@ /** * Defines the ThemeCacheContext service, for "per theme" caching. */ -class ThemeCacheContext implements CacheContextInterface { +class ThemeCacheContext implements CacheContextInterface, ConfigurableCacheContextInterface { /** * The theme manager.