Redirects to another resource
@param string $module
@param string|null $controller
@param string|null $action
@param array $params
@param string $hash
7014
final protected function redirect($module, $controller = null, $action = null, array $params = array(), $hash = null) {
        header('Location: ' . $this->view->url($module, $controller, $action, $params, $hash));
        exit;
    }
297092
public function startup(Controller $controller) {
        $handled = ($this->_handled === array('*') || in_array($controller->action, $this->_handled));

        if ($handled && !$controller->request->is('ajax')) {
            if (isset($controller->Security)) {
                $controller->Security->blackHole($controller, 'You are not authorized to process this request.');
            } else {
                $controller->redirect(null, 401, true);
            }
        }

        $this->controller = $controller;
    }
1302407
public function disable(Module $module)
    {
        if ($this->moduleManager->isCoreModule($module)) {
            return redirect()->route('backend::modules.modules.show', [$module->getLowerName()])
                ->with('error', trans('workshop::modules.module cannot be disabled'));
        }

        $module->disable();
    }
44390
public function canExtended($resource_id, $method_code, $action, $module_id = null) : bool {
		// rearrange controllers
		if (!isset(self::$cached_controllers_by_ids)) {
			self::$cached_controllers_by_ids = [];
			foreach (self::$cached_controllers as $k => $v) {
				self::$cached_controllers_by_ids[$v['id']] = $k;
			}
		}
		// if we got a string
		if (is_string($resource_id)) {
			$resource_id = self::$cached_controllers[$resource_id]['id'] ?? null;
		}
		// if resource is not present we return false
		if (empty(self::$cached_controllers_by_ids[$resource_id])) return false;
		// missing features
		if (!empty(self::$cached_controllers[self::$cached_controllers_by_ids[$resource_id]]['missing_features'])) return false;
		// super admin
		if (\User::get('super_admin')) return true;
		// load all actions from datasource
		if (is_null(self::$cached_actions) && !\Object\Error\Base::$flag_database_tenant_not_found) {
			self::$cached_actions = \Object\ACL\Resources::getStatic('actions', 'primary');
		}
		if (is_string($action)) $action = self::$cached_actions[$action]['id'];
		// see if we have permission overrides
		$permissions = \User::get('permissions');
		if (!empty($permissions)) {
			// process permissions
			$all_actions = $permissions[$resource_id]['AllActions'][-1] ?? [];
			$actual_action = $permissions[$resource_id][$method_code][$action] ?? [];
			$temp = array_merge_hard($all_actions, $actual_action);
			if (!empty($temp)) {
				if (!empty($module_id)) {
					$temp = $temp[$module_id] ?? null;
				} else { // find any active permision
					$temp2 = $temp;
					$temp = null;
					foreach ($temp2 as $k => $v) {
						if ($v === 0) {
							$temp = 0;
							break;
						}
					}
				}
			}
			if ($temp === 0) {
				return true;
			} else if ($temp === 1) {
				return false;
			}
		}
		// load user roles
		$roles = \User::roles();
		// authorized controllers have full access
		if (empty(self::$cached_controllers[self::$cached_controllers_by_ids[$resource_id]]['acl_permission']) && !empty(self::$cached_controllers[self::$cached_controllers_by_ids[$resource_id]]['acl_authorized'])) {
			// if user is logged in
			if (\User::authorized()) return true;
		}
		// go through roles
		foreach ($roles as $v) {
			$temp = $this->processRole($v, $resource_id, $method_code, $action, $module_id);
			if ($temp === 1) {
				return true;
			} else if ($temp === 2) {
				return false;
			}
		}
		// go through teams
		foreach (\User::teams() as $v) {
			$temp = $this->processTeam($v, $resource_id, $method_code, $action, $module_id);
			if ($temp === 1) {
				return true;
			} else if ($temp === 2) {
				return false;
			}
		}
		return false;
	}
45580
public function redirect($to = null, $scope = 'snsapi_userinfo', $state = 'STATE')
    {
        header('Location:' . $this->url($to, $scope, $state));

        exit;
    }
609813
static function run($module_name = null, $controller_name = null, $action = null) {
        try {
            $request = self::getRequest();
            if (self::getConfig()->get('security.csrf_defender')) {
                if ($request->isPost()) {
                    $csrf_token = $request->getPost('_csrftoken');
                    if ($csrf_token != $request->getCookie('_csrftoken')) {
                        exit('CsrfToken Invalid!');
                    }
                } else {
                    if (!$request->hasCookie('_csrftoken')) {
                        setcookie('_csrftoken', \Hiano\Token\Token::generate('_csrftoken'), 0, '/');
                    }
                }
            }


            $module_name or $module_name = self::getModuleName(); // $request->getParameter('module');
            $controller_name or $controller_name = self::getControllerName(); // $request->getParameter('controller');
            $action or $action = self::getActionName(); // $request->getParameter('action');

            $app_path = realpath(HIANO_APP_PATH);
            $controller_dir = $app_path . '/Controller/';
            $view_dir = $app_path . '/View/';
            $module_main_file = $controller_dir . ucfirst($module_name) . '/main.php';
            if (file_exists($module_main_file)) {
                include $module_main_file;
            }

            $view = self::getView();

            $view->set('app', array(
                'parameter' => $request->getParameter(),
                'post' => $request->getPost(),
                'cookie' => $request->getCookie(),
                'session' => $_SESSION,
                'server' => $_SERVER,
                'csrf' => array(
                    'name' => '_csrftoken',
                    'value' => $request->getCookie('_csrftoken')
                )
            ));

            $tpl_dir = $view_dir . '/' . ucfirst($module_name) . '/' . ucfirst($controller_name);
            $view->addTemplateDir($view_dir);
            $view->addTemplateDir($tpl_dir);
            $view->setTemplate($action);


            $ctrl = self::getController($module_name, $controller_name, $request, $view);
            $filter_chain = new Filter\FilterChain(function() use ($ctrl, $view) {
                $action_ret = self::dispatchAction($ctrl, self::getActionName());
                if (is_array($action_ret)) {
                    echo json_encode($action_ret);
                } elseif (is_string($action_ret)) {
                    echo $action_ret;
                } elseif ($action_ret === TRUE or $action_ret === NULL) {
                    $view->display();
                } elseif ($action_ret === FALSE) {
                    //do nothing
                } else {
                    throw new \Exception('错误的动作返回值！');
                }
            });
            if ($filters = self::$filter) {
                $filter_count = count($filters);
                for ($i = 0; $i < $filter_count; $i++) {
                    $f = self::loadFilter($filters[$i]);
                    $filter_chain->addFilter($f);
                }
            }
            $filter_chain->execute();
        } catch (Controller\NoActionException $e) {
            self::forward404();
        } catch (Controller\NoControllerException $e) {
            self::forward404();
        } catch (Controller\NoModuleException $e) {
            self::forward404();
        } catch (\Hiano\RedirectException $e) {
            call_user_func(self::$redirect_handler, $e);
        } catch (StopException $e) {
            
        } catch (\Hiano\ErrorException $e) {
            call_user_func(self::$error_handler, $e);
        }
    }
1067109
private function dispatchMvc($module, $controller, $action, $params)
    {
        return Dispatcher::mvcDispatcher($module, $controller, $action, $params);
    }
510992
public function href(string $controller = null, string $action = null, array $params = null, string $lang = null): string
    {
        return $this->siteHref('', $controller, $action, $params, $lang);
    }
206656
public function redirectToAction($action, $parameters = array(), $status = 302, $headers = array())
	{
		return $this->redirector->action($action, $parameters, $status, $headers);
	}
1171249
static public function encode(?string $module = '', ?string $controller = "", ?string $action = "", ?array $params = []): string
    {
        // 配置中的根
        $url = configDefault('/', 'system', 'host');

        // 配置中的路由模式
        $mode = configDefault('传统模式', 'system', 'url_mode');

        //取默认MCA
        list($defaultM, $defaultC, $defaultA) = self::getMCADefault();

        //如果未提供,则使用默认值
        $module = $module ?: $defaultM;
        $controller = $controller ?: $defaultC;
        $action = $action ?: $defaultA;

        // 根据路由配置进行编码
        $router = configDefault([], 'router');
        foreach ($router as $key => $case) {
            // 这个不是路由配置,而是参数
            if (substr($key, 0, 1) == '_') continue;

            // 如果没有编码这个配置项
            if (!isset($case['encode']) or !$case['encode']) continue;

            //如果编码是一个方法
            if (is_callable($case['encode'])) {
                //调用 回调方法进行转义
                $return = $case['encode']($module, $controller, $action, $params);

                //如果不符合规则,下一条
                if (!$return) continue;

                //处理的结果
                list($pattern, $params) = $return;
                $params = $params ?: [];

                //转义后处理
                return self::encodeMatched($pattern, $params);
            }

            // 取配置,前三项为模块名,控制器,动作名称
            $rule = $case['encode'];
            list ($m, $c, $a) = $rule;

            // 如果控制器与动作相同,使用此规则
            if ($m == $module and $c == $controller and $a == $action) {
                // 把控制器名称和动作名称替换进去
                $pattern = str_replace(['{m}', '{c}', '{a}'], [$module, $controller, $action], $rule[3]);

                //转义后处理
                return self::encodeMatched($pattern, $params);
            }
        }

        // 例 /<m>/<c>/<a>/<k1>/<v1>/<k2>/<v2>/...
        if ($mode == '路径模式') {
            if ($module) $url .= $module . '/';

            // 附加控制器名和动作名
            if ($controller) {
                $url .= $controller . '/';
                if ($action) $url .= $action . '/';
            }

            // 附加参数
            foreach ($params as $key => $value) {
                if (!is_null($value)) $url .= $key . '/' . urlencode($value) . '/';
            }
            return trim($url, '?');
        }

        if ($mode == '传统模式') {
            // 例: /index.php?<k1>=<v1>&<k2=v2>...
            $url .= 'index.php';
        }

        $url .= '?';

        // 取三项参数名
        list ($mName, $cName, $aName) = self::$mcaName;

        // 附加模块名称
        if ($module) $url .= $mName . '=' . $module . '&';

        // 附加控制器名称
        if ($controller) $url .= $cName . '=' . $controller . '&';

        // 附加动作名称
        if ($action) $url .= $aName . '=' . $action . '&';

        // 附加参数
        foreach ($params as $key => $value) {
            $url .= $key . '=' . urlencode('' . $value) . '&';
        }
        return trim(trim($url, '&'), '?');
    }
1125024
public function head($module, $controller): Link
    {
        return $this->addMap(RequestMethod::HEAD, $module, $controller);
    }
1199254
private function controller($module, $controller, $injetion = null) {

        // Check if exist
        if(class_exists($namespace = 'App\\Modules\\' . ucfirst($module) . '\\Controllers\\' . $controller)) {

            return (new $namespace($injetion));
        }
    }
1018537
function(req, res, next) {

        /**
         * If you want to redirect to another controller, uncomment
         */

        var controllers = [];

        fs.readdir(__dirname + '/', function(err, files) {

            if (err) {
                throw err;
            }
            files.forEach(function(file) {
                if(/\.js$/i.test(file)) {
                   if (file !== "AppsController.js") {
                       controllers.push(file.replace('Controller.js', '').toLowerCase());
                   }
                }
            });

            res.render('app', {
                controllers: controllers
            });

        });
    }
11379
public function hasPermission($module, $action, User $user = null) {
		$module = $this->service->getModuleManager()->load($module);
		$action = $module->getActionModel($action);
		return $this->hasActionPermission($action, $user);
	}
287592
public function prepare($module, $action, $data = 'default')
    {
        $request = $this->_createRequest($this->config("REQUEST"));
        if ( ! is_object($request)) {
            return null;
        }
        $request->setModule($module);
        $request->setAction($action);
        $request->prepareRequest($data);

        return $request;
    }
146695
public function handleController(
        $controller, $action = null, array $params = null, $model = null
    ) {

        ! $model || $model = $this->modelFactory->create(null, $model);

        $this->setController(
            $this->controllerFactory->create($params, $controller, $model)
        );

        if (!is_null($action)) {
            $this->setControllerResult(
                $this->executeMethod($this->getController(), $action, $params, $model)
            );
        }
    }
607815
function customHTTPAction( $module, $http, $action )
    {
        $dataType = $this->dataType();
        $this->Module = $module;
        $dataType->customClassAttributeHTTPAction( $http, $action, $this );
        unset( $this->Module );
        $this->Module = null;
    }