/** * 运行应用程序 */ public function run() { $dispatcher = AXION_DISPATCHER::getInstance(); $params = $dispatcher->analyse(); $module = $params['module']; $controller = $params['controller']; $appClass = $module . '_' . $controller; if (!class_exists($appClass)) { throw new AXION_EXCEPTION('无法找到控制器'); } define('ACTION_ClASS', $appClass); self::$module = $module; self::$controller = $controller; /** * 合并调度后的URL参数到$_GET 与 $_REQUEST */ if (isset($params['params'])) { $_GET = array_merge($_GET, $params['params']); $_REQUEST = array_merge($_REQUEST, $_GET); } //捕获控制器的所有非法输出 //ob_start (); //实例化控制器对象 $controller = new $appClass(); if (!$controller instanceof AXION_INTERFACE_CONTROLLER) { throw new AXION_EXCEPTION('非法的控制器对象'); } self::$actionInstance = $controller; //执行action $controller->run(); //获取控制器响应模式 $response = AXION_REQUEST::getResponseFormat(); //定义响应模式常量 self::$responseFormat = $response; //获取控制器请求方法 $method = AXION_REQUEST::getRequestMethod(); self::$method = $method; //设置控制器响应模式 if (!$controller->responseTo()) { $controller->responseTo($response); } //记录程序执行数据 //$initMessage = "Processing sel" . "Controller#" . self::$controller . " (for " . IP . " at " . date ( 'Y-m-d H:i:s' ) . ") [" . self::$method . "]"; //Axion_log::log ( $initMessage, Axion_log::INFO, 'run' ); //实例化渲染器对象 $render = new AXION_RENDER($controller); //$extOutput = ob_get_contents (); //ob_end_clean (); //获取渲染后的数据 $output = $render->render(); echo $output; if (!IS_SERVER_INIT_DONE) { file_put_contents(APPLICATION_PATH . DS . 'serverInit.done', self::$uniqueId); } }