Example #1
0
 function run()
 {
     if ($this->running) {
         throw new \Exception(get_called_class() . '::run() was previously called!');
     }
     $this->running = true;
     $request = Request::getInstance();
     if ($request->exists(self::PATH_INFO_OVERRIDE_PARAM)) {
         $this->pathInfo = $request->get(self::PATH_INFO_OVERRIDE_PARAM, '/');
         $request->delete(self::PATH_INFO_OVERRIDE_PARAM);
     } else {
         $this->pathInfo = \ManiaLib\Utils\Arrays::getNotNull($_SERVER, 'PATH_INFO', '/');
     }
     list($this->controller, $this->action) = Route::getActionAndControllerFromRoute($this->pathInfo);
     $this->calledURL = $request->createLink();
     $viewsNS =& Config::getInstance()->viewsNS;
     $currentViewsNS = Config::getInstance()->namespace . '\\Views\\';
     if (!in_array($currentViewsNS, $viewsNS)) {
         array_unshift($viewsNS, $currentViewsNS);
     }
     try {
         Controller::factory($this->controller)->launch($this->action);
         Response::getInstance()->render();
     } catch (\Exception $e) {
         call_user_func(Bootstrapper::$errorHandlingCallback, $e);
         Response::getInstance()->render();
     }
 }