public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
{
// Passes the request to the container
$this->getContainer()->add('Symfony\\Component\\HttpFoundation\\Request', $request);
try {
$this->emit('request.received', $request);
$dispatcher = $this->getRouter()->getDispatcher();
$response = $dispatcher->dispatch($request->getMethod(), $request->getPathInfo());
$this->emit('response.created', $request, $response);
return $response;
} catch (\Exception $e) {
if (!$catch) {
throw $e;
}
$response = call_user_func($this->exceptionDecorator, $e);
if (!$response instanceof Response) {
throw new \LogicException('Exception decorator did not return an instance of Symfony\\Component\\HttpFoundation\\Response');
}
$this->emit('response.created', $request, $response);
return $response;
}
}