$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?';
}