You are here

class UrlCacheContext in Zircon Profile 8

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

Defines the UrlCacheContext service, for "per page" caching.

Cache context ID: 'url'.

Hierarchy

Expanded class hierarchy of UrlCacheContext

1 string reference to 'UrlCacheContext'
core.services.yml in core/core.services.yml
core/core.services.yml
1 service uses UrlCacheContext
cache_context.url in core/core.services.yml
Drupal\Core\Cache\Context\UrlCacheContext

File

core/lib/Drupal/Core/Cache/Context/UrlCacheContext.php, line 17
Contains \Drupal\Core\Cache\Context\UrlCacheContext.

Namespace

Drupal\Core\Cache\Context
View source
class UrlCacheContext extends RequestStackCacheContextBase implements CacheContextInterface {

  /**
   * {@inheritdoc}
   */
  public static function getLabel() {
    return t('URL');
  }

  /**
   * {@inheritdoc}
   */
  public function getContext() {
    return $this->requestStack
      ->getCurrentRequest()
      ->getUri();
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheableMetadata() {
    return new CacheableMetadata();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RequestStackCacheContextBase::$requestStack protected property The request stack.
RequestStackCacheContextBase::__construct public function Constructs a new RequestStackCacheContextBase class.
UrlCacheContext::getCacheableMetadata public function Gets the cacheability metadata for the context. Overrides CacheContextInterface::getCacheableMetadata
UrlCacheContext::getContext public function Returns the string representation of the cache context. Overrides CacheContextInterface::getContext
UrlCacheContext::getLabel public static function Returns the label of the cache context. Overrides CacheContextInterface::getLabel