aliasManager = $alias_manager; $this->currentPath = $current_path; } /** * Sets the cache key on the alias manager cache decorator. * * KernelEvents::CONTROLLER is used in order to be executed after routing. * * @param \Symfony\Component\HttpKernel\Event\FilterControllerEvent $event * The Event to process. */ public function onKernelController(FilterControllerEvent $event) { // Set the cache key on the alias manager cache decorator. if ($event->getRequestType() == HttpKernelInterface::MASTER_REQUEST) { $this->aliasManager->setCacheKey(rtrim($this->currentPath->getPath($event->getRequest()), '/')); } } /** * Ensures system paths for the request get cached. */ public function onKernelTerminate(PostResponseEvent $event) { $this->aliasManager->writeCache(); } /** * Registers the methods in this class that should be listeners. * * @return array * An array of event listener definitions. */ public static function getSubscribedEvents() { $events[KernelEvents::CONTROLLER][] = ['onKernelController', 200]; $events[KernelEvents::TERMINATE][] = ['onKernelTerminate', 200]; return $events; } }