Back to NomenuRules class

Method parse

public void
parse
(mixed &$segments, mixed &$vars)
Parse a menu-less URL
Parameters
  • array & $segments The URL segments to parse
  • array & $vars The vars that result from the segments
Returns
  • void
Since
  • 3.4
Class: NomenuRules
Project: Joomla

Method parse - Source code

/**
 * Parse a menu-less URL
 *
 * @param   array  &$segments  The URL segments to parse
 * @param   array  &$vars      The vars that result from the segments
 *
 * @return  void
 *
 * @since   3.4
 */
public function parse(&$segments, &$vars)
{
    $active = $this->router->menu->getActive();
    if (!\is_object($active)) {
        $views = $this->router->getViews();
        if (isset($views[$segments[0]])) {
            $vars['view'] = array_shift($segments);
            $view = $views[$vars['view']];
            if (isset($view->key) && isset($segments[0])) {
                if (\is_callable(array($this->router, 'get' . ucfirst($view->name) . 'Id'))) {
                    if ($view->parent_key && $this->router->app->input->get($view->parent_key)) {
                        $vars[$view->parent->key] = $this->router->app->input->get($view->parent_key);
                        $vars[$view->parent_key] = $this->router->app->input->get($view->parent_key);
                    }
                    if ($view->nestable) {
                        $vars[$view->key] = 0;
                        while (count($segments)) {
                            $segment = array_shift($segments);
                            $result = \call_user_func_array(array($this->router, 'get' . ucfirst($view->name) . 'Id'), array($segment, $vars));
                            if (!$result) {
                                array_unshift($segments, $segment);
                                break;
                            }
                            $vars[$view->key] = preg_replace('/-/', ':', $result, 1);
                        }
                    } else {
                        $segment = array_shift($segments);
                        $result = \call_user_func_array(array($this->router, 'get' . ucfirst($view->name) . 'Id'), array($segment, $vars));
                        $vars[$view->key] = preg_replace('/-/', ':', $result, 1);
                    }
                } else {
                    $vars[$view->key] = preg_replace('/-/', ':', array_shift($segments), 1);
                }
            }
        }
    }
}
OSZAR »