class UrlCacheContext in Drupal 8
Same name and namespace in other branches
- 9 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
- class \Drupal\Core\Cache\Context\RequestStackCacheContextBase
- class \Drupal\Core\Cache\Context\UrlCacheContext implements CacheContextInterface
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
File
- core/
lib/ Drupal/ Core/ Cache/ Context/ UrlCacheContext.php, line 12
Namespace
Drupal\Core\Cache\ContextView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RequestStackCacheContextBase:: |
protected | property | The request stack. | |
RequestStackCacheContextBase:: |
public | function | Constructs a new RequestStackCacheContextBase class. | |
UrlCacheContext:: |
public | function |
Gets the cacheability metadata for the context. Overrides CacheContextInterface:: |
|
UrlCacheContext:: |
public | function |
Returns the string representation of the cache context. Overrides CacheContextInterface:: |
|
UrlCacheContext:: |
public static | function |
Returns the label of the cache context. Overrides CacheContextInterface:: |