public function getController(FilterControllerEvent $event)
    {
        $request = $event->getRequest();

        if (($viewBuilder = $this->viewBuilderRegistry->getFromRegistry($request->attributes->get('_controller'))) === null) {
            return;
        }

        $parameterEvent = new FilterViewBuilderParametersEvent(clone $request);
        $this->eventDispatcher->dispatch(ViewEvents::FILTER_BUILDER_PARAMETERS, $parameterEvent);
        $view = $viewBuilder->buildView($parameterEvent->getParameters()->all());
        $request->attributes->set('view', $view);

        // View parameters are added as request attributes so that they are available as controller action parameters
        $request->attributes->add($view->getParameters());

        if (($controllerReference = $view->getControllerReference()) instanceof ControllerReference) {
            $request->attributes->set('_controller', $controllerReference->controller);
            $event->setController($this->controllerResolver->getController($request));
        }
    }