Returns instance of router

@param RoutingConfiguration $configuration
@param Request $request
@return RestRouter
340332
public static function getInstance(RoutingConfiguration $configuration, Request $request): RestRouter
    {
        if (null === self::$instance) {
            self::$instance = new RestRouter($configuration, $request);
        }

        return self::$instance;
    }
705756
public function run(Config $configuration)
    {
        $this->config = $configuration;
        $this->config->set('base', str_replace('app.php', '', $_SERVER['SCRIPT_NAME']));
        try {
            $request = $this->getRequest();
            if (!$this->config->get('routes')) {
                throw new Exception404( "No routes", 1 );
            } else {
                list($controller_name, $action_name, $parameters) = $this->findRoute($request);
            }

            $controller = new $controller_name();
            $controller->$action_name( $parameters );
        } catch ( Exception404 $e ) {
            $e->displayMessage();
        }
    }
576769
public function dispatchToRoute(Request $request)
	{
		// First we will find a route that matches this request. We will also set the
		// route resolver on the request so middlewares assigned to the route will
		// receive access to this route instance for checking of the parameters.
		$route = $this->findRoute($request);

		$request->setRouteResolver(function() use ($route)
		{
			return $route;
		});

		$this->events->fire('router.matched', [$route, $request]);

		// Once we have successfully matched the incoming request to a given route we
		// can call the before filters on that route. This works similar to global
		// filters in that if a response is returned we will not call the route.
		$response = $this->callRouteBefore($route, $request);

		if (is_null($response))
		{
			$response = $this->runRouteWithinStack(
				$route, $request
			);
		}

		$response = $this->prepareResponse($request, $response);

		// After we have a prepared response from the route or filter we will call to
		// the "after" filters to do any last minute processing on this request or
		// response object before the response is returned back to the consumer.
		$this->callRouteAfter($route, $request, $response);

		return $response;
	}
618549
private function getPaginationRelativeUrl(Request $request, array $parameters = array())
    {
        $relativeUrl = new RequestHelper($request, $this->router);

        return $relativeUrl->getRelativeUrl($parameters);
    }
902752
public function route(Request $request)
    {
        foreach ($this->routes as $route) {
            if ($route->matches($request)) {
                return $route;
            }
        }

        return null;
    }
816439
protected function getRoutesFromConfiguration(array $configuration)
    {
        // Result
        $routes = [];

        // Convert routes to same context as from presenter
        foreach ($configuration as $route => $config) {

            // Check for method and set DEFAULT to GET if not set
            if (isset($config->methods) && null !== $config->methods) {
                $methods = explode(',', $config->methods);
            } else {
                $methods = [Doozr_Http::REQUEST_METHOD_GET];
            }

            foreach ($methods as $method) {
                if (false === isset($routes[$method])) {
                    $routes[$method] = [];
                }
                $config->route           = $route;
                $routes[$method][$route] = $config;
            }
        }

        return $routes;
    }
502587
protected function getDataFromRequest(Request $request, $configuration = null)
    {
        if (null === $configuration) {
            $configuration = [
                new ParamConverter(
                    [
                        'name' => 'data',
                        'class' => $this->admin->getEntity(),
                    ]
                ),
            ];
        }
        $this->container->get('sensio_framework_extra.converter.manager')->apply($request, $configuration);

        return $request->attributes->get('data');
    }
266752
public function route(Request $request) : Response
    {
        $method = $request->getMethod();

        /** @var ParsedRoute $route */
        foreach ($this->routeCollection->get($method) as $route) {
            $compiledRoute = $this->compiler->compile($route, $request);

            if ($compiledRoute->isMatch()) {
                $this->matchedRoute = $compiledRoute;

                return $this->dispatcher->dispatch($this->matchedRoute, $request, $this->matchedController);
            }
        }

        // If we've gotten here, we've got a missing route
        throw new HttpException(404);
    }
213393
public function findByRequest(Request $request): ?PageInterface
    {
        if (null !== $route = $request->attributes->get('_route', null)) {
            return $this->findByRoute($route);
        }

        return null;
    }
1125512
public function getConfiguration(Request $request)
    {
        $this->request = $request;

        return [
            'base_uri' => $request->getOptions()->get('base_url'),
            'headers'  => $request->getHeaders()->all(),
            'query'    => $request->getParameters()->all()
        ];
    }
1117380
protected function getStructureRoute(Request $request, PageBridge $content)
    {
        return new Route(
            $this->decodePathInfo($request->getPathInfo()),
            [
                '_controller' => $content->getController(),
                'structure' => $content,
                'partial' => 'true' === $request->get('partial', 'false'),
            ]
        );
    }
211989
public function getInstance(): Router
    {
        if (! isset(self::$instance)) {
            self::$instance = new self();
        }
        
        return self::$instance;
    }
75419
public function showAction(Request $request, $id)
    {
        /** @var ConfiguratorFactory $configuratorFactory */
        $configuratorFactory = $this->getConfiguratorFactory($this->getClassName());
        /** @var CrudConfigurator $crudConfigurator */
        $crudConfigurator = $configuratorFactory->getConfigurator(CrudConfigurator::class);
        /* @var PageConfigurator $pageConfigurator */
        $pageConfigurator = $configuratorFactory->getConfigurator(PageConfigurator::class);
        /* @var GridConfigurator $gridConfigurator */
        $gridConfigurator = $configuratorFactory->getConfigurator(GridConfigurator::class);

        $this->isGrantedOr404Error($crudConfigurator, Constants::ACTION_READ);
        $crud = $crudConfigurator->getCrud();

        $translator = $this->get('translator');
        $translationDomain = $this->getParameter('symfonyid.admin.translation_domain');
        /** @var ModelInterface $model */
        $model = $this->findOr404Error($id);
        /** @var View $view */
        $view = $this->get('symfonyid.admin.view.view');
        $view->setParam('page_title', $translator->trans($pageConfigurator->getTitle(), array(), $translationDomain));
        $view->setParam('page_description', $translator->trans($pageConfigurator->getDescription(), array(), $translationDomain));

        $driver = $this->get('symfonyid.admin.manager.driver_finder')->findDriverForClass($crud->getModelClass());
        $crudFactory = $this->get('symfonyid.admin.crud.crud_factory');
        $crudFactory->setRequest($request);
        $crudFactory->setDriver($driver);
        $crudFactory->setView($view);
        $crudFactory->setTemplate($crudConfigurator->getTemplate()->getShow());
        $showFields = $crud->getShowFields() ?: $gridConfigurator->getColumns(new \ReflectionClass($crud->getModelClass()));

        return $crudFactory->showDetail($model, $showFields, $crud->isAllowDelete());
    }
828884
protected function getRequestedInstanceConfig($paramName = 'instanceId')
    {
        $instanceId = $this->getInstanceIdParam($paramName, null);

        if ($instanceId === null) {
            throw new \Exception("Route param '{$paramName}' required");
        }

        return $this->getInstanceConfig($instanceId);
    }
444807
public final function match(ServerRequestInterface &$request): RouteInterface
   {
       foreach ($this->route as $value) {
           if ($this->matcher->match($request, $value)) {
               return $value;
           }
       }
       throw new RouterException(
           "Can't match "
         . $request->getMethod() . " "
         . $request->getUri()->getPath());
   }
1154279
public function apply(Request $request, ParamConverter $configuration)
    {
        if (null === $parameter = $configuration->getName()) {
            throw new InvalidConfigurationException(InvalidConfigurationException::MISSING_NAME);
        }

        // Check whether we need to let pass anonymous
        $allowAnonymous = false;
        $options = $configuration->getOptions();
        if ($options && isset($options['allowAnonymous']) && true === $options['allowAnonymous']) {
            $allowAnonymous = true;
        }

        $token = $this->tokenStorage->getToken();
        if ($token) {
            $user = $token->getUser();
            if ($user instanceof User) {
                $request->attributes->set($parameter, $user);

                return true;
            } elseif ($allowAnonymous) {
                $request->attributes->set($parameter, null);

                return true;
            }
        }

        throw new AccessDeniedException();
    }
925168
protected function routeCondition( $condition ) {
		if ( $condition === null ) {
			throw new ConfigurationException( 'No route condition specified. Did you miss to call url() or where()?' );
		}

		if ( ! $condition instanceof ConditionInterface ) {
			$condition = $this->condition_factory->make( $condition );
		}

		return $condition;
	}