public function doAction() { $method = $this->_request->getAction() . 'Action'; if ($this->hasAction($method)) { call_user_func(array($this->_controller, $method)); } else { throw new XF_Controller_Exception('Action 不存在', 404); } }
/** * 启动路由器 * @access public * @return void */ public function run() { $this->_request = XF_Controller_Request_Http::getInstance(); $this->_getFinalUri(); $status = $this->_validateRewrite(); if ($status == false) { //是否启用默认路由规则 if (XF_Config::getInstance()->isUseDefaultRouter() == false) { if ($this->_final_uri != '' && $this->_final_uri != '/' && $this->_final_uri != '/index.php') { throw new XF_Controller_Router_Exception('404 Not found!', 404); } else { $this->_setDefault(); } } else { $this->_start(); } } //当前分析到的模块是否有效 if ($this->_request->getModule() == 'unknown') { throw new XF_Controller_Router_Exception('404 Not found!', 404); } if (strtolower($this->_request->getModule()) != 'default' && $this->_close_all_module === true && !isset($this->_open_modules[strtolower($this->_request->getModule())])) { throw new XF_Controller_Router_Exception('The module is close', 404); } if (isset($this->_close_modules[strtolower($this->_request->getModule())])) { throw new XF_Controller_Router_Exception('The module is close', 404); } //当前Action是否禁用了默认路由 if ($this->_request_default_route === TRUE) { if (isset($this->_disabled_default_routes[strtolower($this->_request->getModule() . $this->_request->getController() . $this->_request->getAction())])) { throw new XF_Controller_Router_Exception('The action default router disabled', 404); } } $this->_readOldRequestParams(); }
/** * 执行控制器动作 * @access public * @return void */ public function doAction() { $plugins = XF_Controller_Plugin_Manage::getInstance(); //当前Action是否存在文件缓存 if ($content = $this->_checkCacheContent()) { echo $content; return; } $this->_checkControllerInstance(); $actionName = $this->_request->getAction(); $valiMethod = 'validate' . ucfirst($actionName); $method = $actionName . 'Action'; $methods = get_class_methods($this->_controller); //是否存在Action验证方法 if ($this->hasAction($valiMethod)) { if (call_user_func(array($this->_controller, $valiMethod)) !== true) { $plugins->exception404($this->_request); return; } } //是否存在要执行的Action if ($this->hasAction($method)) { $plugins->preAction($this->_request); call_user_func(array($this->_controller, $method)); $plugins->postAction($this->_request); $this->_render(); $plugins->postOutput(); return; } $plugins->exception404($this->_request); }