Cml\Service\FastRoute::parseUrlParams PHP Method

parseUrlParams() private method

解析uri参数
private parseUrlParams ( $uri )
$uri
    private function parseUrlParams($uri)
    {
        //is_array($action) ? $action['__rest'] = 1 :  ['__rest' => 0, '__action' => $action];
        if (is_array($uri) && !isset($uri['__action'])) {
            self::$urlParams['path'] = $uri[0];
            self::$urlParams['controller'] = $uri[1];
            if (isset($uri['__rest'])) {
                self::$urlParams['action'] = strtolower(isset($_POST['_method']) ? $_POST['_method'] : $_SERVER['REQUEST_METHOD']) . ucfirst($uri[2]);
            } else {
                self::$urlParams['action'] = $uri[2];
            }
        } else {
            $rest = false;
            if (is_array($uri) && $uri['__rest'] === 0) {
                $rest = true;
                $uri = $uri['__action'];
            }
            $path = '/';
            $routeArr = explode('/', $uri);
            if ($rest) {
                self::$urlParams['action'] = strtolower(isset($_POST['_method']) ? $_POST['_method'] : $_SERVER['REQUEST_METHOD']) . ucfirst(array_pop($routeArr));
            } else {
                self::$urlParams['action'] = array_pop($routeArr);
            }
            self::$urlParams['controller'] = ucfirst(array_pop($routeArr));
            $controllerPath = '';
            $routeAppHierarchy = Config::get('route_app_hierarchy', 1);
            $i = 0;
            while ($dir = array_shift($routeArr)) {
                if ($i++ < $routeAppHierarchy) {
                    $path .= $dir . '/';
                } else {
                    $controllerPath .= $dir . '/';
                }
            }
            self::$urlParams['controller'] = $controllerPath . self::$urlParams['controller'];
            unset($routeArr);
            self::$urlParams['path'] = $path ? $path : '/';
            unset($path);
        }
        //定义URL常量
        $subDir = dirname($_SERVER['SCRIPT_NAME']);
        if ($subDir == '/' || $subDir == '\\') {
            $subDir = '';
        }
        //定义项目根目录地址
        self::$urlParams['root'] = $subDir . '/';
    }