/** * 执行指定的动作 * * @return mixed */ function _execute(array $args = array()) { $action_method = 'action' . ucfirst(strtolower($this->context->action_name)); if (!method_exists($this, $action_method)) { return call_user_func($this->context->getIni('dispatcher_on_action_not_found'), $this->context); } $this->_before_execute(); $response = call_user_func_array(array($this, $action_method), $args); $response = $this->_after_execute($response); if (is_null($response) && !is_null($this->view)) { $viewname = $this->_getViewname(); /** * 尝试载入控制器对应的视图类,如果没有找到则使用默认的 QView */ if ($this->view_class) { $view_class_name = $this->view_class; } else { $view_class_name = 'QView'; } $response = new $view_class_name($this->context); $response->viewname = $viewname; $response->viewdata = (array) $this->view; if (!empty($this->view_config['view_dir'])) { $response->view_dir = $this->view_config['view_dir']; } $response->view_layouts = $this->view_layouts; if (!empty($this->view_config['view_layouts_dir'])) { $response->view_layouts_dir = $this->view_config['view_layouts_dir']; } if ($this->context->isAJAX() && empty($this->view_layouts)) { $response->no_view_layouts = true; } if (method_exists($response, $action_method)) { $response->{$action_method}(); } } return $response; }