Get the Route object of the current path.

@return \Berlioz\Core\Services\Routing\RouteInterface|null
@throws \Berlioz\Core\Exception\RuntimeException if application not accessible
768678
public function getRoute(): ?RouteInterface
    {
        if (!is_null($this->getApp())) {
            return $this->getApp()->getService('routing')->getCurrentRoute();
        }

        return null;
    }
68167
public function get($route = null)
    {
        //argument 1 must be a string or null
        Argument::i()->test(1, 'string', 'null');
        
        //if route is null
        if (is_null($route)) {
            //return all routes
            return $this->route;
        }
        
        //if valid route
        if ($this->valid($route)) {
            //return route
            return $this->route[strtolower($route)];
        }
        
        //at this point it is not a route
        //return the same thing
        return $route;
    }
543779
public static function current()
        {
            if ( ! is_null(static::$uri)) {
                return static::$uri;
            }

            // We'll simply get the path info from the Symfony Request instance and then
            // format to meet our needs in the router. If the URI is root, we'll give
            // back a single slash, otherwise we'll strip all of the slashes off.
            $uri = static::format(Request::getPathInfo());

            static::segments($uri);

            return static::$uri = $uri;
        }
237017
protected function getCurrentRoute(): string
    {
        $request = resolve(HttpRequest::class);
        $method = strtoupper($request->getMethod());
        $path = ltrim($request->path(), '/');
        $host = $request->getHost();

        ! is_null($host) && $host = rtrim($host, '/');

        return "{$method} {$host}/{$path}";
    }
732398
public function route()
    {
        if (!$this->route)
        {
            if (php_sapi_name() === 'cli')
            {
                global $argv;
                $this->route = $this->router
                    ->getRoute($argv[1] ?? null, 'console', 'cli');
            }
            else
            {
                $this->route = $this->router
                    ->getRoute($this->urlPath(), $this->domain(), $this->scheme());
            }
        }

        return $this->route;
    }
483794
public static function path()
    {
        $url = '';

        // Get the rest of the URL
        if (!Arr::key('REQUEST_URI', $_SERVER)) {
            // Microsoft IIS doesn't set REQUEST_URI by default
            if ($queryString = Arr::key('QUERY_STRING', $_SERVER, true)) {
                $url .= '?' . $queryString;
            }
        } else {
            $url .= $_SERVER['REQUEST_URI'];
        }

        return $url ?: null;
    }
408117
public function currentRouteAction()
	{
		if ( ! $this->current()) return;

		$action = $this->current()->getAction();

		return isset($action['controller']) ? $action['controller'] : null;
	}
417849
public function getRouteMatch()
    {
        if ($this->routeMatch instanceof RouteMatch) {
            return $this->routeMatch;
        }

        $controller = $this->getController();

        if (!$controller instanceof InjectApplicationEventInterface) {
            throw new Exception\DomainException(
                'Url plugin requires a controller that implements InjectApplicationEventInterface'
            );
        }

        $event      = $controller->getEvent();
        $routeMatch = null;

        if ($event instanceof MvcEvent) {
            $routeMatch = $event->getRouteMatch();
        } elseif ($event instanceof EventInterface) {
            $routeMatch = $event->getParam('route-match', false);
        }

        if (!($routeMatch instanceof RouteMatch)) {
            throw new Exception\RuntimeException('Url plugin requires event compose a route match');
        }

        return $this->routeMatch;
    }
705166
public function getRoute($path = null)
    {
        // check the path
        if (!$path || ($this->path && $path != $this->path)){
            $urlParts = $this->urlPart;
        } else {
            $urlParts = $this->parsePath($path);
        }
        return $this->routeSystem->getRoute($urlParts);
    }
1012384
public function getNavigation()
    {
        if ( empty( $this->menuId ) )
        {
            return null;
        }

        return $this->getMenuModel()
                    ->findNavigation( $this->menuId );
    }
267458
public function get() {
		$this->RoutedStatus = FALSE;

		if ( ! $this->route->isGet() ) {
			return $this;
		}

		if ( is_callable( $this->callable ) ) {
			//$this->RoutedStatus = FALSE;
			return $this;
		}

		$this->middleware = array( 'before' => array(), 'after' => array() );
		self::$FullRender = '';
		$args             = func_get_args();

		if ( ! empty( self::$group ) ) {

			if ( $args[0] == '/' ) {
				$args[0] = substr( self::$group, 0, - 1 );
			} else {
				$args[0] = self::$group . $args[0];
			}

		}

		array_push( Route::$list, $args[0] );
		$this->setCallable( $args );

		return $this;
	}
803763
public function routing()
    {
        // has dispatch.
        $route = null;
        if ($action = $this->getDispatchAction()) {
            $route = new Rule\MatchRule(array('action' => $action));
        }

        // root rule.
        $path = $this->request->getPath();
        if (! $route && $this->_root && $this->_root->match($path)) {
            $route = $this->_root;
        }

        // match rule.
        if (! $route) {
            foreach ($this->_rules as $rule) {
                if ($rule->match($path)) {
                    $route = $rule;
                    break;
                }
            }
        }

        // default rule.
        if (! $route && $this->_default && $this->_default->match($path)) {
            $route = $this->_default;
        }

        // not found
        if (! $route || ! $this->isActionExists($route)) {
            $route = new Rule\NotFoundRule();
        }
        return $route;
    }
1233479
public function getRouteMatch()
    {
        if (null === $this->routeMatch) {
            /** @noinspection PhpUndefinedMethodInspection */
            $this->routeMatch = $this->getEvent()->getRouteMatch();
        }

        return $this->routeMatch;
    }
495754
public function toString()
    {
        $url = $this->scheme.':';
        if (trim($this->host) != '') {
            $url .= '//';
            if (trim($this->user) != '') {
                $url .= $this->user.((trim($this->pass) != '')?':'.$this->pass:'').'@';
            }
            $url .= $this->host;

            if (trim($this->port) != '') {
                $url .= ':'.$this->port;
            }
        }

        $url .= (trim($this->path) != '')?$this->path:'';
        $url .= (trim($this->query) != '')?'?'.$this->query:'';
        $url .= (trim($this->fragment) != '')?'#'.$this->fragment:'';

        if (!self::isValid($url)) {
            throw new RuntimeException('Built URL is not a valid one: '.$url);
        }

        return $url;
    }
1168528
public function getUrl()
    {
        // Ensure in request cycle (even for override).
        if ($this->request === null) {
            return null;
        }

        // Ensure request has been matched
        if (!$this->request->attributes->get('_route')) {
            return null;
        }

        if ($this->override) {
            $this->resolveCurrentOverride();

            return (string) $this->override;
        }

        return $this->urlGenerator->generate(
            $this->request->attributes->get('_route'),
            $this->request->attributes->get('_route_params'),
            UrlGeneratorInterface::ABSOLUTE_URL
        );
    }
1167655
public function getRouter() : RouterInterface
    {
        if (! $this->router instanceof RouterInterface) {
            $router = new Router();
            $resolver = $this->getCallbackResolver();
            if ($resolver instanceof CallbackResolverInterface) {
                $router->setCallbackResolver($resolver);
            }

            $routerCacheFile = $this->getConfiguration('routerCacheFile', false);
            if ($routerCacheFile) {
                $router->setCacheFile($routerCacheFile);
            }

            $this->router = $router;
        }

        return $this->router;
    }
97369
protected function getRoute()
    {
        $request = Yii::$app->request;
        if ($this->isRouteAllowed() && $request->get('route', false)) {
            return Html::encode($request->get('route'));
        }

        return Yii::$app->request->pathInfo;
    }