FOF30\Template\Template::route PHP Метод

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

This method merges the route string with the url parameters defined in current url. The parameters defined in current url, but not given in route string, will automatically reused in the resulting url. But only these following parameters will be reused: option, view, layout, format Example: Assuming that current url is: http://fobar.com/index.php?option=com_foo&view=cpanel Result: http://fobar.com/index.php?option=com_foo&view=categories&layout=tree
public route ( string $route = '' ) : string
$route string The parameters string
Результат string The human readable, complete url
    public function route($route = '')
    {
        $route = trim($route);
        // Special cases
        if ($route == 'index.php' || $route == 'index.php?') {
            $result = $route;
        } elseif (substr($route, 0, 1) == '&') {
            $url = \JURI::getInstance();
            $vars = array();
            parse_str($route, $vars);
            $url->setQuery(array_merge($url->getQuery(true), $vars));
            $result = 'index.php?' . $url->getQuery();
        } else {
            $url = \JURI::getInstance();
            $props = $url->getQuery(true);
            // Strip 'index.php?'
            if (substr($route, 0, 10) == 'index.php?') {
                $route = substr($route, 10);
            }
            // Parse route
            $parts = array();
            parse_str($route, $parts);
            $result = array();
            // Check to see if there is component information in the route if not add it
            if (!isset($parts['option']) && isset($props['option'])) {
                $result[] = 'option=' . $props['option'];
            }
            // Add the layout information to the route only if it's not 'default'
            if (!isset($parts['view']) && isset($props['view'])) {
                $result[] = 'view=' . $props['view'];
                if (!isset($parts['layout']) && isset($props['layout'])) {
                    $result[] = 'layout=' . $props['layout'];
                }
            }
            // Add the format information to the URL only if it's not 'html'
            if (!isset($parts['format']) && isset($props['format']) && $props['format'] != 'html') {
                $result[] = 'format=' . $props['format'];
            }
            // Reconstruct the route
            if (!empty($route)) {
                $result[] = $route;
            }
            $result = 'index.php?' . implode('&', $result);
        }
        return \JRoute::_($result);
    }