Basecoat\Routing::parseUrl PHP Метод

parseUrl() публичный Метод

public parseUrl ( $url = null )
    public function parseUrl($url = null)
    {
        if (is_null($url) && is_null($this->requested_url)) {
            $this->setUrl();
        }
        // Check what URL format is in use
        if ($this->settings['use_pretty_urls']) {
            // Determine path relative to document root
            $url_path = str_replace(dirname($_SERVER['PHP_SELF']), '', $this->requested_url);
            $url_path = trim(parse_url($url_path, PHP_URL_PATH), '/');
            if ($url_path == '') {
                $this->run_routes = array('/');
            } else {
                $this->run_routes = explode('/', $url_path);
            }
        } else {
            /*
             The route is determined by parsing the "page" url parameter
             Multiple routes are delimited by a period (.)
            */
            parse_str(parse_url($url, PHP_URL_QUERY), $tmp_get);
            if (isset($_GET[$this->settings['route_param']]) && $_GET[$this->settings['route_param']] != '') {
                // Create a run routes list, to be used by subroutes
                $this->run_routes = explode('.', $_GET[$this->settings['route_param']]);
            } else {
                // Use default route
                $this->run_routes = array('/');
            }
        }
        //
        // Set the first route as the current run route
        // trim out leading/trailing . for security
        $this->requested_route = trim(array_shift($this->run_routes), '.');
        return $this->requested_route;
    }