class IpCacheContext
Same name and namespace in other branches
- 11.x 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 extends \Drupal\Core\Cache\Context\CacheContextInterface implements \Drupal\Core\Cache\Context\RequestStackCacheContextBase
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 12
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();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.