class ProtocolVersionCacheContext
Same name in other branches
- 9 core/lib/Drupal/Core/Cache/Context/ProtocolVersionCacheContext.php \Drupal\Core\Cache\Context\ProtocolVersionCacheContext
- 8.9.x core/lib/Drupal/Core/Cache/Context/ProtocolVersionCacheContext.php \Drupal\Core\Cache\Context\ProtocolVersionCacheContext
- 10 core/lib/Drupal/Core/Cache/Context/ProtocolVersionCacheContext.php \Drupal\Core\Cache\Context\ProtocolVersionCacheContext
Defines the ProtocolVersionCacheContext service, for "per protocol" caching.
Useful to differentiate between HTTP/1.1 and HTTP/2.0 responses for example, to allow responses to be optimized for protocol-specific characteristics.
Cache context ID: 'protocol_version'.
Hierarchy
- class \Drupal\Core\Cache\Context\RequestStackCacheContextBase
- class \Drupal\Core\Cache\Context\ProtocolVersionCacheContext extends \Drupal\Core\Cache\Context\RequestStackCacheContextBase implements \Drupal\Core\Cache\Context\CacheContextInterface
Expanded class hierarchy of ProtocolVersionCacheContext
1 file declares its use of ProtocolVersionCacheContext
- ProtocolVersionCacheContextTest.php in core/
tests/ Drupal/ Tests/ Core/ Cache/ Context/ ProtocolVersionCacheContextTest.php
File
-
core/
lib/ Drupal/ Core/ Cache/ Context/ ProtocolVersionCacheContext.php, line 15
Namespace
Drupal\Core\Cache\ContextView source
class ProtocolVersionCacheContext extends RequestStackCacheContextBase implements CacheContextInterface {
/**
* {@inheritdoc}
*/
public static function getLabel() {
return t('Protocol version');
}
/**
* {@inheritdoc}
*/
public function getContext() {
return $this->requestStack
->getCurrentRequest()
->getProtocolVersion();
}
/**
* {@inheritdoc}
*/
public function getCacheableMetadata() {
return new CacheableMetadata();
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
ProtocolVersionCacheContext::getCacheableMetadata | public | function | Gets the cacheability metadata for the context. | Overrides CacheContextInterface::getCacheableMetadata |
ProtocolVersionCacheContext::getContext | public | function | Returns the string representation of the cache context. | Overrides CacheContextInterface::getContext |
ProtocolVersionCacheContext::getLabel | public static | function | Returns the label of the cache context. | Overrides CacheContextInterface::getLabel |
RequestStackCacheContextBase::$requestStack | protected | property | The request stack. | |
RequestStackCacheContextBase::__construct | public | function | Constructs a new RequestStackCacheContextBase class. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.