private function ExecuteAction() { //禁止使用模块检测 if (in_array(MODULE, C('http.deny_module'))) { throw new Exception(MODULE . '模块禁止使用'); } $class = MODULE . '\\controller\\' . CONTROLLER; //控制器不存在 if (!class_exists($class)) { throw new Exception("{$class} 不存在"); } $controller = new $class(); //执行动作 try { $action = new ReflectionMethod($controller, ACTION); if ($action->isPublic()) { //控制器前置钩子 $this->app->make('Hook')->listen('controller_begin'); //执行动作 $result = call_user_func_array(array($controller, ACTION), Route::getArg()); if (IS_AJAX) { Response::ajax($result); } else { die($result); } } else { throw new ReflectionException('动作不存在'); } } catch (ReflectionException $e) { $action = new ReflectionMethod($controller, '__call'); $action->invokeArgs($controller, array(ACTION, '')); } }
private function ExecuteAction() { //控制器实例 $class = ucfirst(MODULE) . '\\Controller\\' . ucfirst(CONTROLLER) . 'Controller'; //控制器不存在 if (!class_exists($class)) { throw new Exception("{$class} 不存在"); } $controller = new $class(); //执行动作 try { $action = new ReflectionMethod($controller, ACTION); if ($action->isPublic()) { call_user_func_array(array($controller, ACTION), Route::getArg()); } else { throw new ReflectionException('动作不存在'); } } catch (ReflectionException $e) { $action = new ReflectionMethod($controller, '__call'); $action->invokeArgs($controller, array(ACTION, '')); } }
private function ExecuteAction() { //禁止使用模块检测 if (in_array(MODULE, C('http.deny_module'))) { throw new Exception(MODULE . '模块禁止使用'); } if (defined('APP_GROUP_PATH')) { $class = APP . '\\' . ucfirst(MODULE) . '\\Controller\\' . ucfirst(CONTROLLER) . 'Controller'; } else { $class = ucfirst(MODULE) . '\\Controller\\' . ucfirst(CONTROLLER) . 'Controller'; } //控制器不存在 if (!class_exists($class)) { throw new Exception("{$class} 不存在"); } $controller = new $class(); //执行动作 try { $action = new ReflectionMethod($controller, ACTION); if ($action->isPublic()) { call_user_func_array(array($controller, ACTION), Route::getArg()); } else { throw new ReflectionException('动作不存在'); } } catch (ReflectionException $e) { $action = new ReflectionMethod($controller, '__call'); $action->invokeArgs($controller, array(ACTION, '')); } }