Skip to content

Instantly share code, notes, and snippets.

@anvodev
Last active May 3, 2020 15:31
Show Gist options
  • Select an option

  • Save anvodev/6a581835616af08d0f0d4a879b72feb6 to your computer and use it in GitHub Desktop.

Select an option

Save anvodev/6a581835616af08d0f0d4a879b72feb6 to your computer and use it in GitHub Desktop.
finish handling the request and return the response
//vendor/symfony/http-kernel/HttpKernel.php
<?php
private function handleRaw(Request $request, int $type = self::MASTER_REQUEST): Response
{
//...previous stages
// call controller
$response = $controller(...$arguments);
// view
if (!$response instanceof Response) {
$event = new ViewEvent($this, $request, $type, $response);
$this->dispatcher->dispatch($event, KernelEvents::VIEW);
//...
}
return $this->filterResponse($response, $request, $type);
}
private function filterResponse(Response $response, Request $request, int $type): Response
{
$event = new ResponseEvent($this, $request, $type, $response);
$this->dispatcher->dispatch($event, KernelEvents::RESPONSE);
$this->finishRequest($request, $type);
return $event->getResponse();
}
private function finishRequest(Request $request, int $type)
{
$this->dispatcher->dispatch(new FinishRequestEvent($this, $request, $type), KernelEvents::FINISH_REQUEST);
$this->requestStack->pop();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment