function WorkspaceRequestSubscriber::onKernelRequest

Same name in other branches
  1. 9 core/modules/workspaces/src/EventSubscriber/WorkspaceRequestSubscriber.php \Drupal\workspaces\EventSubscriber\WorkspaceRequestSubscriber::onKernelRequest()
  2. 8.9.x core/modules/workspaces/src/EventSubscriber/WorkspaceRequestSubscriber.php \Drupal\workspaces\EventSubscriber\WorkspaceRequestSubscriber::onKernelRequest()
  3. 10 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\RequestEvent $event: An event object.

File

core/modules/workspaces/src/EventSubscriber/WorkspaceRequestSubscriber.php, line 30

Class

WorkspaceRequestSubscriber
Provides a event subscriber for setting workspace-specific cache keys.

Namespace

Drupal\workspaces\EventSubscriber

Code

public function onKernelRequest(RequestEvent $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.