class RngEventCacheContext in RNG - Events and Registrations 8
Same name and namespace in other branches
- 8.2 src/Cache/Context/RngEventCacheContext.php \Drupal\rng\Cache\Context\RngEventCacheContext
- 3.x src/Cache/Context/RngEventCacheContext.php \Drupal\rng\Cache\Context\RngEventCacheContext
A context for the current rng_event.
Cache context ID: 'rng_event'.
Hierarchy
- class \Drupal\rng\Cache\Context\RngEventCacheContext implements CacheContextInterface
Expanded class hierarchy of RngEventCacheContext
1 string reference to 'RngEventCacheContext'
1 service uses RngEventCacheContext
File
- src/
Cache/ Context/ RngEventCacheContext.php, line 14
Namespace
Drupal\rng\Cache\ContextView source
class RngEventCacheContext implements CacheContextInterface {
/**
* The RNG event from the current route.
*
* @var \Drupal\Core\Entity\EntityInterface
*/
protected $rng_event;
/**
* Constructs a new RngEventCacheContext service..
*
* @param \Drupal\Core\Plugin\Context\ContextProviderInterface $context_provider
* The rng_event context service.
*/
public function __construct(ContextProviderInterface $context_provider) {
/** @var \Drupal\rng\ContextProvider\RngEventRouteContext $context_provider */
$contexts = $context_provider
->getRuntimeContexts([
'rng_event',
]);
$this->rng_event = $contexts['rng_event']
->getContextValue();
}
/**
* {@inheritdoc}
*/
public static function getLabel() {
return t('RNG Event');
}
/**
* {@inheritdoc}
*/
public function getContext() {
if (isset($this->rng_event)) {
return $this->rng_event
->getEntityTypeId() . ':' . $this->rng_event
->id();
}
return '';
}
/**
* {@inheritdoc}
*/
public function getCacheableMetadata() {
return new CacheableMetadata();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RngEventCacheContext:: |
protected | property | The RNG event from the current route. | |
RngEventCacheContext:: |
public | function |
Gets the cacheability metadata for the context. Overrides CacheContextInterface:: |
|
RngEventCacheContext:: |
public | function |
Returns the string representation of the cache context. Overrides CacheContextInterface:: |
|
RngEventCacheContext:: |
public static | function |
Returns the label of the cache context. Overrides CacheContextInterface:: |
|
RngEventCacheContext:: |
public | function | Constructs a new RngEventCacheContext service.. |