构造分页URL地址
@param $module string 模块名称
@param  $controller string 控制器名称
@param  $action string 动作名称
@param  $params array 参数
@return string
437344
public function url($module = null, $controller = null, $action = null, $params = array()):string
    {
        $module=$module?:self::$module;
        $controller=$controller?:self::$controller;
        $action=$action?:self::$action;

        // 如果参数中指定了page,换成_PAGE
        if (isset ($params ['page'])) {
            $page = $params ['page'];
            unset ($params ['page']);
            $params [self::PAGE] = $page;
        } else {
            $params [self::PAGE] = $this->page;
        }

        // 调整参数中的分页尺寸参数
        if (isset ($params ['size'])) {
            $size = $params ['size'];
            unset ($params ['size']);
            $params [self::SIZE] = $size;
        } else {
            $params [self::SIZE] = $this->size;
        }

        // 调整参数中的排序依据参数
        if (isset ($params ['sort'])) {
            $sort = $params ['sort'];
            unset ($params ['sort']);
            $params [self::SORT] = $sort;
        } else {
            $params [self::SORT] = $this->sort;
        }

        // 调整参数中的排序方向参数
        if (isset ($params ['dir'])) {
            $dir = $params ['dir'];
            unset ($params ['dir']);
            $params [self::DIR] = $dir;
        } else {
            $params [self::DIR] = $this->dir;
        }

        // 把搜索条件也加上
        if ($this->where) {
            $params = array_merge($params, $this->where);
        }

        // 构造URL
        return url($module, $controller, $action, $params);
    }
416390
private function getControllerActionAnnotations($controller, $action)
    {
        if ($controller instanceof \Closure) {
            return $this->annotation->readFunction($controller);
        }

        return $this->annotation->readMethod($controller, $action . 'Action');
    }
7297
private function _routeCron($src, $controller, $action) {
        $this->request->name = '-' . $src . '_' . $controller . '_' . $action;
        $this->request->src = $src;
        $this->request->controller = $controller;
        $this->request->action = $action;
        $this->request->auth = new Auth($this->request->src);
        $this->_route = true;
    }
710778
public function getFullUrl(
        $module = self::DEFAULT_MODULE,
        $controller = self::DEFAULT_CONTROLLER,
        array $params = []
    ): string {
        $scheme = Request::getUri()->getScheme() . '://';
        $host = Request::getUri()->getHost();
        $port = Request::getUri()->getPort();
        if ($port && !\in_array($port, [80, 443], true)) {
            $host .= ':' . $port;
        }
        $url = $this->getUrl($module, $controller, $params);
        return $scheme . $host . $url;
    }
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, '&'), '?');
    }
677568
protected function bindToModule($request, $url, $controller)
    {
        $array  = explode('|', $url, 2);
        $action = !empty($array[0]) ? $array[0] : $this->router->config('default_action');
        $param  = [];

        if (!empty($array[1])) {
            $this->parseUrlParams($request, $array[1], $param);
        }

        return new ModuleDispatch($request, $this, $controller . '/' . $action, $param);
    }
864472
public static function factory($module, $action)
    {
        $listApiToReport = self::getMapOfModuleActionsToReport();
        $api = $module . '.' . ucfirst($action);

        if (!array_key_exists($api, $listApiToReport)) {
            return null;
        }

        $klassName = $listApiToReport[$api];

        return new $klassName;
    }
497950
public static function isModule(string $module, string $controller = null, string $action = null): bool
    {
        $route = Application::route();
        if ($module === $route->getModuleUrl()) {
            if ($controller === null) {
                return true;
            } else {
                if ($controller === $route->getControllerUrl()) {
                    // now we have matched module and controller
                    if ($action === null) {
                        return true;
                    } else {
                        return ($action === $route->getActionUrl());
                    }
                } else {
                    return false;
                }
            }
        } else {
            return false;
        }
    }
61021
public static function is(string $controller, string $action): bool
    {
        return $controller == Application::route()->getControllerUrl() && $action == Application::route()->getActionUrl();
    }
206020
public function getResourceName($controller, $action = null)
    {
        if (isset($action)) {
            return sprintf('controller/%s:%s', $controller, strtolower($action));
        }

        return sprintf('controller/%s', $controller);
    }
743601
final public function url($module, $controller = null, $action = null, array $params = array(), $hash = null) {
        return $this->view->url($module, $controller, $action, $params, $hash);
    }
1313420
public function loadController($module, $controller) {

		if(false === is_string($module)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($module)), E_USER_ERROR);
		}

		if(false === is_string($controller)) {
			return trigger_error(sprintf('Argument 2 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($controller)), E_USER_ERROR);
		}

		$folders 	= explode('.', $controller); //Convert dots to directory separators
		$amount 	= count($folders) - 1;
		$namespace	= '';

		foreach($folders as $index => $folder) {

			if($amount === $index) {
				
				$controller = Application :: get(['prefix', 'controller']) . $folder;
				$namespace .= $controller;

				break;
			}

			$namespace 	.= $folder . DIRECTORY_SEPARATOR;
		}

		$controller = str_replace(DIRECTORY_SEPARATOR, '\\', $module . DIRECTORY_SEPARATOR . Application :: get(['directory', 'controller']) . $namespace);
			
		return $controller;
	}
970637
public static function getAnnotationParams($controller, $action)
    {
        $result = [];

        $reflection = new \ReflectionClass($controller);
        $res = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC);
        foreach ($res as $method) {
            if ($method->name == $action) {
                $annotation = $method->getDocComment();
                if (strpos($annotation, '@doc') !== false) {
                    //$result[$version][$model]['all'] = $annotation;
                    //描述
                    preg_match('/@desc([^\n]+)/', $annotation, $desc);
                    $result['desc'] = isset($desc[1]) ? trim($desc[1]) : '';
                    //参数
                    preg_match_all('/@param([^\n]+)/', $annotation, $params);
                    foreach ($params[1] as $key => $val) {
                        $tmp = explode(' ', preg_replace('/\s(\s+)/', ' ', trim($val)));
                        isset($tmp[3]) || $tmp[3] = 'N';
                        substr($tmp[1], 0, 1) == '$' && $tmp[1] = substr($tmp[1], 1);
                        $result['params'][] = $tmp;
                    }

                    //请求示例
                    preg_match('/@req(.+?)(\*\s*?@|\*\/)/s', $annotation, $reqEg);
                    $result['req'] = isset($reqEg[1]) ? self::formatCode($reqEg[1]) : '';

                    //请求成功示例
                    preg_match('/@success(.+?)(\*\s*?@|\*\/)/s', $annotation, $success);
                    $result['success'] = isset($success[1]) ? self::formatCode($success[1]) : '';

                    //请求失败示例
                    preg_match('/@error(.+?)(\*\s*?@|\*\/)/s', $annotation, $error);
                    $result['error'] = isset($error[1]) ? self::formatCode($error[1]) : '';
                }
            }
        }
        return $result;
    }
269035
private function analyseAction($controller) {
        $urlParam = explode('-', $controller);
        switch (count($urlParam)) {
            case 0:
                break;
            case 1:
                $this->controller = $urlParam[0];
                break;
            case 2:
                $this->controller = $urlParam[0];
                $_REQUEST['_1'] = $_GET['_1'] = $urlParam[1];
                break;
            default:
                $this->controller = $urlParam[0];
                foreach ($urlParam as $k => $v) {
                    if ($k === 0) {
                        continue;
                    }
                    $_REQUEST['_' . $k] = $_GET['_' . $k] = $v;
                }
                break;
        }
    }
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;
    }
602953
public function buildUrl($controller, $action, array $args = array(), array $get = array())
    {
        $url = $this->buildDestination($controller, $action, $args);
        if (!$this->cleanUrlsEnabled()) {
            $url = $this->entryPoint.$url;
        }
        if ($get) {
            $url .= '?'.http_build_query($get);
        }

        return $url;
    }
975798
public function toRoute($action, $params=[])
    {
        $params = (array)$params;
        $url = URL::route($this->routePrefix . '.' . $action, $params);

        if ($passThruParams = $this->getPassThruParams()) {
            $url .= '?' . http_build_query($passThruParams);
        }

        return $url;

    }