예제 #1
0
파일: Cml.php 프로젝트: linhecheng/cmlphp
 /**
  * 启动应用
  *
  * @param callable $initDi 注入依赖
  */
 public static function runApp(callable $initDi)
 {
     self::$run = true;
     self::onlyInitEnvironmentNotRunController($initDi);
     Plugin::hook('cml.before_run_controller');
     $controllerAction = Cml::getContainer()->make('cml_route')->getControllerAndAction();
     if ($controllerAction) {
         Cml::$debug && Debug::addTipInfo(Lang::get('_CML_ACTION_CONTROLLER_', $controllerAction['class']));
         $controller = new $controllerAction['class']();
         call_user_func([$controller, "runAppController"], $controllerAction['action']);
         //运行
     } else {
         self::montFor404Page();
         if (self::$debug) {
             throw new ControllerNotFoundException(Lang::get('_CONTROLLER_NOT_FOUND_'));
         } else {
             Response::show404Page();
         }
     }
     //输出Debug模式的信息
     self::cmlStop();
 }