function HttpKernel::handleRaw
Handles a request to convert it to a response.
Exceptions are not caught.
Throws
\LogicException If one of the listener does not behave as expected
NotFoundHttpException When controller cannot be found
1 call to HttpKernel::handleRaw()
- HttpKernel::handle in vendor/
symfony/ http-kernel/ HttpKernel.php - Handles a Request to convert it to a Response.
File
-
vendor/
symfony/ http-kernel/ HttpKernel.php, line 155
Class
- HttpKernel
- HttpKernel notifies events to convert a Request object to a Response one.
Namespace
Symfony\Component\HttpKernelCode
private function handleRaw(Request $request, int $type = self::MAIN_REQUEST) : Response {
// request
$event = new RequestEvent($this, $request, $type);
$this->dispatcher
->dispatch($event, KernelEvents::REQUEST);
if ($event->hasResponse()) {
return $this->filterResponse($event->getResponse(), $request, $type);
}
// load controller
if (false === ($controller = $this->resolver
->getController($request))) {
throw new NotFoundHttpException(\sprintf('Unable to find the controller for path "%s". The route is wrongly configured.', $request->getPathInfo()));
}
$event = new ControllerEvent($this, $controller, $request, $type);
$this->dispatcher
->dispatch($event, KernelEvents::CONTROLLER);
$controller = $event->getController();
// controller arguments
$arguments = $this->argumentResolver
->getArguments($request, $controller, $event->getControllerReflector());
$event = new ControllerArgumentsEvent($this, $event, $arguments, $request, $type);
$this->dispatcher
->dispatch($event, KernelEvents::CONTROLLER_ARGUMENTS);
$controller = $event->getController();
$arguments = $event->getArguments();
// call controller
$response = $controller(...$arguments);
// view
if (!$response instanceof Response) {
$event = new ViewEvent($this, $request, $type, $response, $event);
$this->dispatcher
->dispatch($event, KernelEvents::VIEW);
if ($event->hasResponse()) {
$response = $event->getResponse();
}
else {
$msg = \sprintf('The controller must return a "Symfony\\Component\\HttpFoundation\\Response" object but it returned %s.', $this->varToString($response));
// the user may have forgotten to return something
if (null === $response) {
$msg .= ' Did you forget to add a return statement somewhere in your controller?';
}
throw new ControllerDoesNotReturnResponseException($msg, $controller, __FILE__, __LINE__ - 17);
}
}
return $this->filterResponse($response, $request, $type);
}