Auto resolve a Route from URL by separator

@since   1.0
@param   string $arsUrlValueList Liste of url part.
@return  void
438389
private static function autoResolve($arsUrlValueList)
    {
        $sController = 'Index';
        $sAction = 'index';
        $arsParamList = array();
        foreach ($arsUrlValueList as $nIndexValue => $sUrlValue) {
            if ($nIndexValue == 0) {
                $sController = $sUrlValue;
            } elseif ($nIndexValue == 1) {
                $sAction = $sUrlValue;
            } else {
                if (isset($arsUrlValueList[$nIndexValue]) && $nIndexValue % 2 == 0) {
                    $sParamName = $arsUrlValueList[$nIndexValue];
                    $sParamValue = null;
                    if (isset($arsUrlValueList[$nIndexValue + 1])) {
                        $sParamValue = $arsUrlValueList[$nIndexValue + 1];
                    }
                    $arsParamList[$sParamName] = $sParamValue;
                }
            }
        }
        // Set controller
        self::setController($sController);
        // Set action to route action
        self::setAction($sAction);
        // Set param list
        self::setParameter($arsParamList);
    }
579992
public function setURL($url)
    {
        if (!$this->validateURL($url)) {
            throw new \InvalidArgumentException(sprintf('The URL "%s" is invalid.', $url));
        }

        $this->url = $url;
        $this->endpoint = null;
    }
1086077
public function setUrl( $url ) {
		if ( $url !== static::WILDCARD ) {
			$url = UrlUtility::addLeadingSlash( UrlUtility::addTrailingSlash( $url ) );
		}

		$this->url = $url;
	}
802389
public function addRoute($uri, $callback, $delimiter = Map::DEFAULT_URL_DELIMITER)
    {
        try {
            /**
             * if the uri is empty throw an exception
             */
            if (empty($uri)) {
                throw new RouteException(sprintf(_('There is no Route entered %s'), $uri));
            }

            // class for mapping
            $route = new Map($uri, $callback, $delimiter);
            $this->rootNode->appendToBranch($uri, $route, Map::DEFAULT_URL_DELIMITER);

        } catch (RouteException $e) {
            throw $e;
        }

    }
14984
public function createRoute(IRouter $routes, string $url): void
	{
		$this->createPageRoute($routes, $url);
		$this->createDefaultPageRoutes($routes, $url);
	}
1075846
public function uri(
        $resolverPath,
        $attributes    = array(),
        $withHost      = true
    )
    {
        return $this->routeTranslator->generateUri(
            $resolverPath,
            $attributes,
            $withHost
        );
    }
1338719
private function resolveName($name)
    {
        if ($name !== null) {
            return $name;
        }

        if (!isset($this->defaults['route'])) {
            throw new RouterException('Unable to make "self" url - default route was not defined.');
        }

        return $this->defaults['route'];
    }
33472
private function resolveOrder($routes, $order){
        if (isset($routes[$order])) {
            return $this->resolveOrder($routes, $order + 1);
        } else {
            return $order;
        }
    }
1331610
public function resolveRawAlias(string $uri): ?array
    {
        $this->normalizeUri($uri, $name);

        while (isset($this->aliases[$name])) {
            $alias = $this->aliases[$name];
            $name = $alias['alias'];
        }

        return $alias ?? null;
    }
696806
public function redirect($url = null, $exitAfter = true)
    {
        if (empty($url)) {
            $authRequest = $this->_stateMgr->get('authRequest');
            /* @var AuthRequest $authRequest */
            if ($authRequest) {
                $url = $authRequest->getReturnUrl();
                $this->_stateMgr->set('authRequest');
            }
        }
        parent::redirect($url, $exitAfter);
    }
365843
protected function mapWebRoutes(): void
    {
        $file = $this->basePath.'routes/web.php';

        if (file_exists($file)) {
            $this->loadRoutesFrom(
                Route::middleware('web')
                ->group($file));
        }
    }
1090722
protected function fixUrlPath(array &$parts)
    {
        $server = &$this->server;
        if (isset($parts['path'])) {
            $parts['path'] = rawurldecode($parts['path']);

            // fix PATH_INFO
            if (isset($server['PATH_INFO'])) {
                $uri = explode(
                    $server['PATH_INFO'],
                    $server['REQUEST_URI']
                );
                $server['PATH_INFO'] =
                    str_replace($uri[0], '', $parts['path']);
            } else {
                $server['PATH_INFO'] = $parts['path'];
            }

            // fix REQUEST_URI
            $server['REQUEST_URI'] = $parts['path'] .
                (
                    empty($server['QUERY_STRING']) ? '' :
                    ('?' . $server['QUERY_STRING'])
                );
        }
    }
1308670
public function execute(Routes $routes): void
	{
		$routeCollection = [];

		// Build table rows

		foreach($routes->getRoutes() as $route)
		{
			// Normalize action name

			$action = ($route->getAction() instanceof Closure) ? 'Closure' : $route->getAction();

			// Build table row

			$routeCollection[] =
			[
				$route->getRoute(),
				implode(', ', $route->getMethods()),
				$action,
				implode(', ', $route->getMiddleware()),
				implode(', ', $route->getConstraints()),
				(string) $route->getName(),
			];
		}

		// Draw table

		$headers =
		[
			'<green>Route</green>',
			'<green>Allowed methods</green>',
			'<green>Action</green>',
			'<green>Middleware *</green>',
			'<green>Constraints **</green>',
			'<green>Name</green>',
		];

		$this->table($headers, $routeCollection);

		$this->write('<green>*</green> <faded>Global middleware is not listed.</faded>');
		$this->write('<green>**</green> <faded>Global constraints are not listed.</faded>');
	}
1043001
private function searchRedirect(): void
    {
        // calculated depend of language
        $pathway = $this->getPathInfo();
        /** @var array $routing */
        $routing = App::$Properties->getAll('Routing');

        if (!Any::isArray($routing) || !isset($routing['Redirect']) || !Any::isArray($routing['Redirect'])) {
            return;
        }

        // check if source uri is key in redirect target map
        if (array_key_exists($pathway, $routing['Redirect'])) {
            $target = $this->getSchemeAndHttpHost(); // . $this->getBasePath() . '/' . rtrim($routing['Redirect'][$pathway], '/');
            if ($this->getBasePath() !== null && !Str::likeEmpty($this->getBasePath())) {
                $target .= '/' . $this->getBasePath();
            }
            $target .= rtrim($routing['Redirect'][$pathway], '/');
            $redirect = new RedirectResponse($target);
            $redirect->send();
            exit();
        }
    }
454743
public static function forward($url, $initialize = true, $finalize = true) {
		$u = self::parseUrl ( $url );
		if (is_array ( Router::getRoutes () ) && ($ru = Router::getRoute ( $url )) !== false) {
			if (\is_array ( $ru )) {
				if (is_callable ( $ru [0] )) {
					self::runCallable ( $ru );
				} else {
					self::_preRunAction ( $ru, $initialize, $finalize );
				}
			} else {
				echo $ru; // Displays route response from cache
			}
		} else {
			self::setCtrlNS ();
			$u [0] = self::$ctrlNS . $u [0];
			self::_preRunAction ( $u, $initialize, $finalize );
		}
	}
662296
public function resolveRouteParameters(IRoute $route) {
        $parameters = $route->getParameters();
        $resolvers = $this->getResolvers();
        $invoker = $this->getParameterResolverInvoker();

        foreach ($parameters as $name => $parameter) {
            $resolver = array_get($resolvers, $name);

            if ($resolver instanceof IRouteResolver) {
                $value = $invoker->invoke($resolver->getResolver(), $parameter);

                if ($value === null) {
                    return false;
                }

                $parameters[$name] = $value;
            }
        }

        $route->setParameters($parameters);

        return true;
    }
54142
public function resolve()
    {
       $url = $this->request->url();
       $tmp = explode('/', $url);
       $last_seg = end($tmp);

       return $this->repository->findBySlug($last_seg);
    }