function WorkspaceRequestSubscriber::onKernelRequest
Same name in other branches
- 9 core/modules/workspaces/src/EventSubscriber/WorkspaceRequestSubscriber.php \Drupal\workspaces\EventSubscriber\WorkspaceRequestSubscriber::onKernelRequest()
- 10 core/modules/workspaces/src/EventSubscriber/WorkspaceRequestSubscriber.php \Drupal\workspaces\EventSubscriber\WorkspaceRequestSubscriber::onKernelRequest()
- 11.x core/modules/workspaces/src/EventSubscriber/WorkspaceRequestSubscriber.php \Drupal\workspaces\EventSubscriber\WorkspaceRequestSubscriber::onKernelRequest()
Adds the active workspace as a cache key part to the route provider.
Parameters
\Symfony\Component\HttpKernel\Event\GetResponseEvent $event: An event object.
File
-
core/
modules/ workspaces/ src/ EventSubscriber/ WorkspaceRequestSubscriber.php, line 89
Class
- WorkspaceRequestSubscriber
- Provides a event subscriber for setting workspace-specific cache keys.
Namespace
Drupal\workspaces\EventSubscriberCode
public function onKernelRequest(GetResponseEvent $event) {
if ($this->workspaceManager
->hasActiveWorkspace() && $this->routeProvider instanceof CacheableRouteProviderInterface) {
$this->routeProvider
->addExtraCacheKeyPart('workspace', $this->workspaceManager
->getActiveWorkspace()
->id());
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.