public function getBlock($blockname = '') { $_currentNameSpace = \fec\helpers\CModule::param("_currentNameSpace"); if (empty($_currentNameSpace)) { $message = "Modules Param '_currentNameSpace' is not set , you can set like fecadmin\\Module"; throw new \yii\web\HttpException(406, $message); } $modulesDir = "\\" . $_currentNameSpace . "\\block\\"; $url_key = \fec\helpers\CUrl::getUrlKey(); $url_key = trim($url_key, "/"); $url_key = substr($url_key, strpos($url_key, "/") + 1); $url_key_arr = explode("/", $url_key); if (!isset($url_key_arr[1])) { $url_key_arr[1] = 'index'; } if ($blockname) { $url_key_arr[count($url_key_arr) - 1] = ucfirst($blockname); } else { $url_key_arr[count($url_key_arr) - 1] = ucfirst($url_key_arr[count($url_key_arr) - 1]); } $block_space = implode("\\", $url_key_arr); $blockFile = $modulesDir . $block_space; //echo $blockFile;exit; return new $blockFile(); }
public function actions() { $return = []; $module_token = Yii::$app->request->post('module_token'); $this_module_token = \fec\helpers\CModule::getToken(); if ($module_token != $this_module_token) { $return['ack'] = false; $return['ack_description'] = "modules token is not right"; $return['content'] = $module_token . '#' . $this_module_token; echo json_encode($return); exit; } $r = $this->getControllerAndAction(); $t_controller = $r['controller']; $t_action = $r['action']; $current_remote_function_param_array = Yii::$app->request->post('current_remote_function_param_array'); $current_remote_function_param_array = unserialize($current_remote_function_param_array); $param = !empty($current_remote_function_param_array) && is_array($current_remote_function_param_array) ? $current_remote_function_param_array : []; $current_namespace = $this->_name_space; $module_o_dir = str_replace("\\controllers", "\\o", $current_namespace); $function_exec = $module_o_dir . "\\" . $t_controller . "::" . $t_action; $data = \call_user_func_array($function_exec, $param); $data = json_decode($data); $return['ack'] = true; $return['ack_description'] = "success"; $return['content'] = $data; # 把模块更新的session更新到redis上面,以供其他模块使用 session_commit(); echo json_encode($return); exit; }