{@inheritdoc}

@throws \InvalidArgumentException When route does not exist
556352
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $router = $this->getContainer()->get($this->getRouterServiceId());
        $name = $input->getArgument('name');
        $helper = new DescriptorHelper();

        if ($name) {
            $route = $router->getRouteCollection()->get($name);
            if (!$route) {
                throw new \InvalidArgumentException(sprintf('The route "%s" does not exist.', $name));
            }
            $this->convertItinerary($route);
            $helper->describe($output, $route, [
                'format' => $input->getOption('format'),
                'raw_text' => $input->getOption('raw'),
                'name' => $name,
            ]);
        } else {
            $routes = $router->getRouteCollection();

            foreach ($routes as $route) {
                $this->convertItinerary($route);
            }

            $helper->describe($output, $routes, [
                'format' => $input->getOption('format'),
                'raw_text' => $input->getOption('raw'),
                false,
            ]);
        }
    }
365897
public function setCatchAll(...$parameters)
    {
        if (count($parameters) === 1) {
            $this->routes['catchAll'] = ['closure' => $parameters[0], 'groupArgs' => []];
        } elseif (count($parameters) === 2) {
            $this->routes['catchAll'] = ['closure' => $parameters[1], 'groupArgs' => $parameters[0]];
        } else {
            throw new \InvalidArgumentException;
        }
    }
139172
public function route($url) {
		if (!isset($this->routes[$this->getHttpMethod()])) {
			throw new RouterException("REQUEST_METHOD does not exist : url = $url");
		}

		foreach ($this->routes[$this->getHttpMethod()] as $route) {
			$matches = $route->match($url);

			if (is_array($matches)) {
				return $route->execute($matches);
			}
		}

		throw new RouterException("No route matches the URL $url");
	}
974637
public function map($methods, $pattern, $handler)
    {
        if (!is_string($pattern)) {
            throw new InvalidArgumentException('Route pattern must be a string');
        }

        // Prepend parent group pattern(s)
        if ($this->routeGroups) {
            $pattern = $this->processGroups().$pattern;
        }

        // Add route
        $route = new Route($methods, $pattern, $handler, $this->routeGroups);
        $this->routes[] = $route;

        return $route;
    }
559258
public function execute(Request $request, Route $route, $parameters)
    {
        $request->attributes->set('_controller', $this->getControllerCallback());
        $app = Facade::getFacadeApplication();
        $controllerResolver = $app->make(ApplicationAwareControllerResolver::class);
        $callback = $controllerResolver->getController($request);
        $argumentsResolver = $app->make(ArgumentResolver::class);

        $arguments = $argumentsResolver->getArguments($request, $callback);
        $controller = $callback[0];
        $method = $callback[1];

        if (method_exists($controller, 'on_start')) {
            $controller->on_start();
        }

        if (method_exists($controller, 'runAction')) {
            $response = $controller->runAction($method, $arguments);
        } else {
            $response = call_user_func_array([$controller, $method], $arguments);
        }

        if ($response instanceof Response) {
            // note, our RedirectResponse doesn't extend Response, it extends symfony2 response
            return $response;
        }

        if ($response instanceof AbstractView) {
            $content = $response->render();
        } else if (method_exists($controller, 'getViewObject')) {
            $content = null;
            $view = $controller->getViewObject();
            if (is_object($view)) {
                $view->setController($controller);
                if (isset($view) && $view instanceof AbstractView) {
                    $content = $view->render();
                }
            }
        } else {
            $content = $response;
        }

        if (is_object($content)) {
            return $content;
        }

        $response = new Response();
        $response->setContent($content);
        return $response;
    }
308095
public function setPath(string $path) : Request
    {
        if (strpos($path, '?') !== false) {
            throw new \InvalidArgumentException('The request path must not contain a query string.');
        }

        $this->path = $path;

        return $this->updateRequestUri();
    }
1182515
public function execute($route, array $parameters = array(), \Exedra\Http\ServerRequest $request = null)
    {
        $route = $this->baseRoute($route);

        $request = $request ? : $this->request;

        return $this->app->execute($route, $parameters, $request);
    }
692112
public function setRoute(string $route = null, array $params = []): ButtonInterface
    {
        if ($this->isVisibility()) {
            if ($route === null) {
                $url = '#';
            } else {
                $url = '#';
                if (app('router')->has($route)) {
                    $url = route($route, $params);
                } else {
                    $this->setVisible(false);
                }
            }
            $this->setUrl($url);
        }

        return $this;
    }
1056695
public function dispatch($route, $request)
    {
        $request->setParam('Closure', $route[4]);

        if(isset($route[3]) && is_string($route[3])) {
            $view = $route[3];
            $data = $route[4];
            return ['view' => [$view, $data]];
        }
        elseif(isset($route[2]) && is_string($route[2])) {
            list($controller, $method) = explode('@', $route[2]);
            return ['controller' => [$controller, $method]];
        }
        elseif(isset($route[2]) && ($route[2] instanceof Closure || get_class($route[2]) === "Closure")) {
            $function = $route[2];
            $reflectionFunction = new ReflectionFunction($function);
            $numReqParam = $reflectionFunction->getNumberOfRequiredParameters();
            if($numReqParam > count($request->getParam('Closure'))) {
                throw new Exception('Invaliding number of required parameter passed in route\'s callable function: '.$route[1]);
            }
            ob_start();
            if($request->getParam('Closure') !== false && is_array($request->getParam('Closure')) ) {
                $return = call_user_func_array($route[2], $request->getParam('Closure'));
            }
            else {
                //$function();
                throw new Exception('Invaliding parameter passed in route\'s callable function: '.$route[1]);
            }
            $output = ob_get_clean();
            return ['output' => [$output, $return]];
        }
        else {
            throw new Exception('Invaliding route is registered for: '.$route[1]);
        }
    }
1256582
private function buildValidRoute(Route $route): void
    {
        //add to route array the passed uri for param check when call
        $matches = $this->routeMatches;

        //route match and there is a subpattern with action
        if (\count($matches) > 1) {
            //assume that subpattern rapresent action
            $route->action = $matches[1];

            //url clean
            $route->url = \preg_replace('`\([0-9A-Za-z\|]++\)`', $matches[1], $route->url);
        }

        $route->param = $this->buildParam($route);

        $this->route = $route;
    }
1251345
public function action($action, $parameters = array(), $absolute = true)
	{
		if ($this->rootNamespace && ! (strpos($action, '\\') === 0))
		{
			$action = $this->rootNamespace.'\\'.$action;
		}
		else
		{
			$action = trim($action, '\\');
		}

		if ( ! is_null($route = $this->routes->getByAction($action)))
		{
			 return $this->toRoute($route, $parameters, $absolute);
		}

		throw new InvalidArgumentException("Action {$action} not defined.");
	}
1264405
private function insertDefaultParameterValues(Route $route, array $missing, array $parameters)
    {
        $values = $route->getDefaultValues();
        foreach ($missing as $key => $pattern) {
            if (isset($values[$key])) {
                $parameters[$key] = $values[$key];
                unset($missing[$key]);
            }
        }
        if (!empty($missing)) {
            $params = join(', ', array_keys($missing));
            throw new \InvalidArgumentException("Parameters not set: {$params}");
        }

        return $parameters;
    }
816533
private function route_exists() : bool {
		if ( property_exists( $this, 'routes' ) ) {
			return array_key_exists( $this->__method_name, $this->routes );
		}
		return false;
	}
614454
public function redirectToRoute($routeName, array $parameters = [])
    {
        $url = $this->router->getRouteUrlByName($routeName, $parameters);
        if (!$url) {
            throw new \Parable\Framework\Exception("Can't redirect to route, '{$routeName}' does not exist.");
        }
        $this->response->redirect($this->url->getUrl($url));
    }
662403
public function registerRawRouting(array $routes, PackageResolver $resolver)
    {
        foreach ($routes as $key => &$route) {
            // Package
            if (isset($route['package'])) {
                if (!isset($route['pattern'])) {
                    throw new \InvalidArgumentException(sprintf('Route need pattern: %s', print_r($route, true)));
                }

                if (!$resolver->exists($route['package'])) {
                    throw new \InvalidArgumentException(sprintf(
                        'Package %s not exists when register routing: %s.',
                        $route['package'],
                        $key
                    ));
                }

                $package = $resolver->getPackage($route['package']);

                $package->loadRouting($this, $route['pattern']);

                continue;
            }

            // Simple route
            $this->addRouteByConfig($key, $route);
        }

        return $this;
    }
813394
function build(iRouterStack $router)
    {
        foreach($this->routes as $routeName => $routeValuable)
        {
            $route = $routeValuable;

            if ( is_string($routeName) && is_array($routeValuable) ) {
                // when route provided as array options
                $route = $this->_attainRouteFromArray($routeName, $routeValuable);
                $override = (isset($routeValuable['override']))  ? $routeValuable['override'] : true;
                $priority = (isset($routeValuable['priority']))  ? $routeValuable['priority'] : null;
            }

            if (! $route instanceof  iRoute )
                throw new \InvalidArgumentException(sprintf(
                    'Invalid argument provided. ("%s")'
                    , \Poirot\Std\flatten($routeValuable)
                ));



            # add router
            if ( isset($override) && isset($priority) )
                ## just if override option provided
                $router->add($route, $override, $priority);
            else
                ## using default value
                $router->add($route);
        }
    }
99705
private function route(RequestInterface $request): ?Route
    {
        $routes = $this->match($request);

        if (empty($routes)) {
            throw new Exception('No route found', Exception::HTTP_NOT_FOUND);
        }

        $route = $this->guard($request, $routes);

        if (empty($route)) {
            throw new Exception('Method not allowed', Exception::HTTP_METHOD_NOT_ALLOWED);
        }

        $route = $this->overlay($route);

        foreach (array_reverse($this->namespaces) as $namespace) {
            $route['namespace'] = $namespace;

            try {
                return new Route(
                    $route['namespace'],
                    $route['module'],
                    $route['controller'],
                    $route['action'],
                    $route['parameters']
                );
            } catch (Exception $e) {
                continue;
            }
        }

        throw new Exception('Invalid controller/action for this route', Exception::HTTP_INTERNAL_SERVER_ERROR);
    }