class IpCacheContext in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Cache/Context/IpCacheContext.php \Drupal\Core\Cache\Context\IpCacheContext
Defines the IpCacheContext service, for "per IP address" caching.
Cache context ID: 'ip'.
Hierarchy
- class \Drupal\Core\Cache\Context\RequestStackCacheContextBase
- class \Drupal\Core\Cache\Context\IpCacheContext implements CacheContextInterface
Expanded class hierarchy of IpCacheContext
1 string reference to 'IpCacheContext'
- core.services.yml in core/
core.services.yml - core/core.services.yml
1 service uses IpCacheContext
File
- core/
lib/ Drupal/ Core/ Cache/ Context/ IpCacheContext.php, line 17 - Contains \Drupal\Core\Cache\Context\IpCacheContext.
Namespace
Drupal\Core\Cache\ContextView source
class IpCacheContext extends RequestStackCacheContextBase implements CacheContextInterface {
/**
* {@inheritdoc}
*/
public static function getLabel() {
return t('IP address');
}
/**
* {@inheritdoc}
*/
public function getContext() {
return $this->requestStack
->getCurrentRequest()
->getClientIp();
}
/**
* {@inheritdoc}
*/
public function getCacheableMetadata() {
return new CacheableMetadata();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
IpCacheContext:: |
public | function |
Gets the cacheability metadata for the context. Overrides CacheContextInterface:: |
|
IpCacheContext:: |
public | function |
Returns the string representation of the cache context. Overrides CacheContextInterface:: |
|
IpCacheContext:: |
public static | function |
Returns the label of the cache context. Overrides CacheContextInterface:: |
|
RequestStackCacheContextBase:: |
protected | property | The request stack. | |
RequestStackCacheContextBase:: |
public | function | Constructs a new RequestStackCacheContextBase class. |