/**
  * Constructor
  * 
  * @param array $config
  */
 public function __construct(array $config = [])
 {
     parent::__construct($config);
     $request = Services::request(null, true);
     $this->json['request_uri'] = (string) $request->uri;
     Hooks::on('post_controller', [$this, 'sendLogs'], HOOKS_PRIORITY_HIGH);
 }
Beispiel #2
0
 /**
  * The class entry point. This is where the magic happens and all
  * of the framework pieces are pulled together and shown how to
  * make beautiful music together. Or something like that. :)
  * 
  * @param RouteCollectionInterface $routes
  */
 public function run(RouteCollectionInterface $routes = null)
 {
     $this->startBenchmark();
     //--------------------------------------------------------------------
     // Is there a "pre-system" hook?
     //--------------------------------------------------------------------
     Hooks::trigger('pre_system');
     $this->getRequestObject();
     $this->getResponseObject();
     $this->forceSecureAccess();
     try {
         $this->tryToRouteIt($routes);
         //--------------------------------------------------------------------
         // Are there any "pre-controller" hooks?
         //--------------------------------------------------------------------
         Hooks::trigger('pre_controller');
         $this->startController();
         // Closure controller has run in startController().
         if (!is_callable($this->controller)) {
             $controller = $this->createController();
             //--------------------------------------------------------------------
             // Is there a "post_controller_constructor" hook?
             //--------------------------------------------------------------------
             Hooks::trigger('post_controller_constructor');
             $this->runController($controller);
         }
         //--------------------------------------------------------------------
         // Is there a "post_controller" hook?
         //--------------------------------------------------------------------
         Hooks::trigger('post_controller');
         $this->gatherOutput();
         $this->sendResponse();
         //--------------------------------------------------------------------
         // Is there a post-system hook?
         //--------------------------------------------------------------------
         Hooks::trigger('post_system');
     } catch (Router\RedirectException $e) {
         $logger = Services::logger();
         $logger->info('REDIRECTED ROUTE at ' . $e->getMessage());
         // If the route is a 'redirect' route, it throws
         // the exception with the $to as the message
         $this->response->redirect($e->getMessage(), 'auto', $e->getCode());
         $this->callExit(EXIT_SUCCESS);
     } catch (HTTP\RedirectException $e) {
         $this->callExit(EXIT_SUCCESS);
     } catch (PageNotFoundException $e) {
         $this->display404errors($e);
     }
 }