public function onEventException(Application $app, \Exception $e) { $response = $app->response('', 500); if ($e instanceof HttpException) { $response->setStatusCode($e->getStatusCode()); } if ($app->getParameter('debug')) { $response->setContent($this->prettyException($e)); } $app->setResponse($response); }
public function onEventRequest(Application $app, Request $request) { $matcher = $app->getRouter()->getMatcher(); $route = $matcher->match($request->getMethod(), $request->getPathInfo()); if ($route != null) { $request->attributes->set('_route', $route); } if ($matcher->isNeedRedirect()) { $url = $matcher->getRedirectUrl(); $app->setResponse($app->redirect($url, 301)); $app->stopEventPropagation(); } }