class CacheContexts in Render cache 7.2
Same name in this branch
- 7.2 src/Cache/CacheContexts.php \Drupal\render_cache\Cache\CacheContexts
- 7.2 lib/Drupal/Core/Cache/CacheContexts.php \Drupal\Core\Cache\CacheContexts
Defines the CacheContexts service.
Provides CacheContexts service using the render_cache container.
Note: The original Drupal 8 CacheContexts service uses the Symfony ContainerInterface, which is not available here. So we over- write the constructor to enable us to use the functionality of the stock file.
Hierarchy
- class \Drupal\Core\Cache\CacheContexts
- class \Drupal\render_cache\Cache\CacheContexts
Expanded class hierarchy of CacheContexts
1 file declares its use of CacheContexts
- CacheContextsTest.php in tests/
src/ Cache/ CacheContextsTest.php - Contains \Drupal\render_cache\Tests\Cache\CacheContextsTest
File
- src/
Cache/ CacheContexts.php, line 25 - Contains \Drupal\render_cache\Cache\CacheContexts
Namespace
Drupal\render_cache\CacheView source
class CacheContexts extends DrupalCacheContexts {
/**
* The service container.
*
* @var \Drupal\service_container\DependencyInjection\ContainerInterface
*/
protected $container;
/**
* Constructs a CacheContexts object.
*
* @param \Drupal\service_container\DependencyInjection\ContainerInterface $container
* The current service container.
* @param array $contexts
* An array of key-value pairs, where the keys are service names (which also
* serve as the corresponding cache context token) and the values are the
* cache context labels.
*/
public function __construct(ContainerInterface $container, array $contexts) {
$this->container = $container;
$this->contexts = $contexts;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CacheContexts:: |
protected | property |
The service container. Overrides CacheContexts:: |
|
CacheContexts:: |
protected | property | Available cache contexts and corresponding labels. | |
CacheContexts:: |
public | function | Converts cache context tokens to string representations of the context. | |
CacheContexts:: |
public | function | Provides an array of available cache contexts. | |
CacheContexts:: |
protected | function | Provides the string representation of a cache context. | |
CacheContexts:: |
public | function | Provides an array of available cache context labels. | |
CacheContexts:: |
protected | function | Retrieves a service from the container. | |
CacheContexts:: |
public | function |
Constructs a CacheContexts object. Overrides CacheContexts:: |