You are here

public function WorkspaceRequestSubscriber::onKernelRequest in Drupal 9

Same name and namespace in other branches
  1. 8 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 89

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());
  }
}