class QueryArgsCacheContext in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Cache/Context/QueryArgsCacheContext.php \Drupal\Core\Cache\Context\QueryArgsCacheContext
Defines the QueryArgsCacheContext service, for "per query args" caching.
Cache context ID: 'url.query_args' (to vary by all query arguments). Calculated cache context ID: 'url.query_args:%key', e.g.'url.query_args:foo' (to vary by the 'foo' query argument).
Hierarchy
- class \Drupal\Core\Cache\Context\RequestStackCacheContextBase
- class \Drupal\Core\Cache\Context\QueryArgsCacheContext implements CalculatedCacheContextInterface
Expanded class hierarchy of QueryArgsCacheContext
1 string reference to 'QueryArgsCacheContext'
- core.services.yml in core/
core.services.yml - core/core.services.yml
1 service uses QueryArgsCacheContext
File
- core/
lib/ Drupal/ Core/ Cache/ Context/ QueryArgsCacheContext.php, line 19 - Contains \Drupal\Core\Cache\Context\QueryArgsCacheContext.
Namespace
Drupal\Core\Cache\ContextView source
class QueryArgsCacheContext extends RequestStackCacheContextBase implements CalculatedCacheContextInterface {
/**
* {@inheritdoc}
*/
public static function getLabel() {
return t('Query arguments');
}
/**
* {@inheritdoc}
*/
public function getContext($query_arg = NULL) {
if ($query_arg === NULL) {
return $this->requestStack
->getCurrentRequest()
->getQueryString();
}
else {
return $this->requestStack
->getCurrentRequest()->query
->get($query_arg);
}
}
/**
* {@inheritdoc}
*/
public function getCacheableMetadata($query_arg = NULL) {
return new CacheableMetadata();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
QueryArgsCacheContext:: |
public | function |
Gets the cacheability metadata for the context based on the parameter value. Overrides CalculatedCacheContextInterface:: |
|
QueryArgsCacheContext:: |
public | function |
Returns the string representation of the cache context. Overrides CalculatedCacheContextInterface:: |
|
QueryArgsCacheContext:: |
public static | function |
Returns the label of the cache context. Overrides CalculatedCacheContextInterface:: |
|
RequestStackCacheContextBase:: |
protected | property | The request stack. | |
RequestStackCacheContextBase:: |
public | function | Constructs a new RequestStackCacheContextBase class. |