public function PageEventVariables::addCacheContext in Hook Event Dispatcher 8
Add a cache context to the page template.
Parameters
string $context: A cache context such as 'url.path'.
Return value
$this PageEventVariables
File
- src/
Event/ Preprocess/ Variables/ PageEventVariables.php, line 117
Class
- PageEventVariables
- Class PageEventVariables.
Namespace
Drupal\hook_event_dispatcher\Event\Preprocess\VariablesCode
public function addCacheContext($context) {
$this->variables['#cache']['contexts'][] = $context;
return $this;
}