Exemple #1
0
 /**
  * Register Whoops as an exception handler.
  *
  * @param Application $app The application container
  */
 public function __construct(Application $app)
 {
     $app['whoops'] = new Run();
     $app['whoops']->pushHandler(new PrettyPageHandler());
     $app['whoops']->register();
     parent::__construct($app);
 }
Exemple #2
0
 /**
  * Compile all the routes and match the resulting regex against the current request.
  *
  * The handlers associated with all matched segments and methods are assembled and executed.
  *
  * @return mixed The last handler output
  *
  * @throws NotFoundHttpException if no matching route is found
  * @throws MethodNotAllowedException if no matching method is found for the route
  */
 public function run()
 {
     $request = $this->request();
     $result = $this->app['router.dispatcher']->dispatch($request->getMethod(), $request->getPathInfo());
     switch ($result[0]) {
         case Dispatcher::NOT_FOUND:
             throw new NotFoundHttpException();
             break;
         case Dispatcher::METHOD_NOT_ALLOWED:
             $methods = $result[1];
             throw new MethodNotAllowedHttpException($methods);
             break;
         case Dispatcher::FOUND:
             $this->context->params($result[2]);
             $this->handlers = $result[1];
             break;
     }
     return parent::run();
 }