/** * {@inheritDoc} */ public function handleRequest(Request $request) { $match = $this->router->match($request); if ($match === null) { throw new HttpNotFoundException('No route matches the request.'); } $controller = $this->instantiator->instantiate($match->controller); return $this->actionDispatcher->dispatch($request, $match, $controller); }
/** * {@inheritDoc} */ public function dispatch(Request $request, MatchedRoute $match, $controller) { $isControllerEventListener = $controller instanceof ControllerEventListenerInterface; if ($isControllerEventListener) { $response = $controller->onRequest($request); if ($response) { return $response; } } $response = $this->dispatcher->dispatch($request, $match, $controller); if ($isControllerEventListener) { $response = $controller->onResponse($request, $response) ?: $response; } return $response; }