function WorkspaceRequestSubscriber::onKernelController
Same name 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);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.