public function WorkspaceRequestSubscriber::onKernelController in Drupal 8
Same name and namespace in other branches
- 9 core/modules/workspaces/src/EventSubscriber/WorkspaceRequestSubscriber.php \Drupal\workspaces\EventSubscriber\WorkspaceRequestSubscriber::onKernelController()
Sets the cache key on the alias manager cache decorator.
KernelEvents::CONTROLLER is used in order to be executed after routing.
Parameters
\Symfony\Component\HttpKernel\Event\FilterControllerEvent $event: The Event to process.
File
- core/
modules/ workspaces/ src/ EventSubscriber/ WorkspaceRequestSubscriber.php, line 75
Class
- WorkspaceRequestSubscriber
- Provides a event subscriber for setting workspace-specific cache keys.
Namespace
Drupal\workspaces\EventSubscriberCode
public function onKernelController(FilterControllerEvent $event) {
// Set the cache key on the alias manager cache decorator.
if ($event
->isMasterRequest() && $this->workspaceManager
->hasActiveWorkspace()) {
$cache_key = $this->workspaceManager
->getActiveWorkspace()
->id() . ':' . rtrim($this->currentPath
->getPath($event
->getRequest()), '/');
$this->aliasManager
->setCacheKey($cache_key);
}
}