Example #1
0
 /**
  * Run the application.
  *
  * @api
  */
 public function dispatch()
 {
     # get current context from URL
     try {
         Router::resolve(isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : '/');
         Router::updateHtaccess();
         #Router::updateRules();
     } catch (\Exception $e) {
         Session::addErrorMsg($e->getMessage());
     }
     // from here we'll capture every output
     ob_start();
     // we need the session this early, (feel free to remove the following line and get stuck with session problems)
     Session::getInstance();
     $module = Router::getModule();
     $action = Router::getAction();
     $view = $this->handleRequest($module, $action);
     // threat all unwanted output as error output
     $errors = ob_get_clean();
     if (trim($errors) !== '') {
         Session::addErrorMsg($errors);
     }
     // finally deliver page
     $view->display();
 }