You are here

interface CacheContextInterface in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Cache/Context/CacheContextInterface.php \Drupal\Core\Cache\Context\CacheContextInterface

Provides an interface for defining a cache context service.

Hierarchy

Expanded class hierarchy of CacheContextInterface

All classes that implement CacheContextInterface

6 files declare their use of CacheContextInterface
BookNavigationCacheContext.php in core/modules/book/src/Cache/BookNavigationCacheContext.php
Contains \Drupal\book\Cache\BookNavigationCacheContext.
CacheContextsManagerTest.php in core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php
Contains \Drupal\Tests\Core\Cache\Context\CacheContextsManagerTest.
ConfigOverrideIntegrationTestCacheContext.php in core/modules/config/tests/config_override_integration_test/src/Cache/ConfigOverrideIntegrationTestCacheContext.php
Contains \Drupal\config_override_integration_test\Cache\ConfigOverrideIntegrationTestCacheContext.
EntityTestViewGrantsCacheContext.php in core/modules/system/tests/modules/entity_test/src/Cache/EntityTestViewGrantsCacheContext.php
Contains \Drupal\entity_test\Cache\EntityTestViewGrantsCacheContext.
PirateDayCacheContext.php in core/modules/config/tests/config_override_test/src/Cache/PirateDayCacheContext.php
Contains \Drupal\config_override_test\Cache\PirateDayCacheContext.

... See full list

File

core/lib/Drupal/Core/Cache/Context/CacheContextInterface.php, line 13
Contains \Drupal\Core\Cache\Context\CacheContextInterface.

Namespace

Drupal\Core\Cache\Context
View source
interface CacheContextInterface {

  /**
   * Returns the label of the cache context.
   *
   * @return string
   *   The label of the cache context.
   */
  public static function getLabel();

  /**
   * Returns the string representation of the cache context.
   *
   * A cache context service's name is used as a token (placeholder) cache key,
   * and is then replaced with the string returned by this method.
   *
   * @return string
   *   The string representation of the cache context.
   */
  public function getContext();

  /**
   * Gets the cacheability metadata for the context.
   *
   * There are three valid cases for the returned CacheableMetadata object:
   * - An empty object means this can be optimized away safely.
   * - A max-age of 0 means that this context can never be optimized away. It
   *   will never bubble up and cache tags will not be used.
   * - Any non-zero max-age and cache tags will bubble up into the cache item
   *   if this is optimized away to allow for invalidation if the context
   *   value changes.
   *
   *
   * @return \Drupal\Core\Cache\CacheableMetadata
   *   A cacheable metadata object.
   */
  public function getCacheableMetadata();

}

Members

Namesort descending Modifiers Type Description Overrides
CacheContextInterface::getCacheableMetadata public function Gets the cacheability metadata for the context. 17
CacheContextInterface::getContext public function Returns the string representation of the cache context. 17
CacheContextInterface::getLabel public static function Returns the label of the cache context. 17