Slide 50
Slide 50 text
public function handle(Request $request, $type, $catch)
{
$event = new GetResponseEvent($this, $request, $type);
$this->dispatcher->dispatch('kernel.request', $event);
if ($event->hasResponse()) {
return $this->filterResponse($event->getResponse(), $request, $type);
}
$controller = $this->resolver->resolve($request);
$response = call_user_func($controller);
return $this->filterResponse($response, $request, $type);
}
private function filterResponse(Response $response, Request $request, $type)
{
$event = new FilterResponseEvent(
$this, $request, $type, $response
);
$this->dispatcher->dispatch('kernel.response', $event);
$response = $event->getResponse();
$event = new FinishRequestEvent($this, $request, $type);
$this->dispatcher->dispatch('kernel.finish_request', $event);
return $response;
}