コード例 #1
0
ファイル: App.php プロジェクト: ukrcms/ukrcms
 /**
  * Run Application
  *
  * @author  Ivan Scherbak <*****@*****.**>
  * @throws \Exception
  */
 public function run()
 {
     try {
         # start parse request usin url class
         $controllerName = $this->url->getControllerName();
         $actionName = $this->url->getActionName();
         if (!$controllerName) {
             throw new \Exception('Controller name is empty');
         }
         if (!$actionName) {
             throw new \Exception('Action name is empty');
         }
         # get names of controller and action
         $controllerRealName = $this->getControllerClassName($controllerName);
         $actionRelName = $this->getActionName($actionName);
         $this->controller = new $controllerRealName();
         # validation of action
         if (!is_callable(array($this->controller, $actionRelName))) {
             throw new \Exception('Action #' . $actionRelName . ' in controller #' . $controllerRealName . ' can not be call');
         }
         return $this->controller->{$actionRelName}();
     } catch (\Exception $exc) {
         # exception handler
         self::showError($exc);
         \Uc::errorHandler($exc);
         # mail admin about error
     }
     return false;
 }