Iterates over $restRouteCollection, and returns the corresponding RouteCollection of OPTIONS REST routes.

@param RouteCollection $restRouteCollection

@return RouteCollection
777833
public function mapCollection(RouteCollection $restRouteCollection)
    {
        $optionsRouteCollection = new RouteCollection();

        foreach ($restRouteCollection->all() as $restRoute) {
            $optionsRouteName = $this->mapper->getOptionsRouteName($restRoute);

            $optionsRoute = $optionsRouteCollection->get($optionsRouteName);
            if ($optionsRoute === null) {
                $optionsRoute = $this->mapper->mapRoute($restRoute);
            } else {
                $optionsRoute = $this->mapper->mergeMethodsDefault($optionsRoute, $restRoute);
            }

            $optionsRouteCollection->add($optionsRouteName, $optionsRoute);
        }

        return $optionsRouteCollection;
    }
461444
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $routeCollection = new RouteCollection();
        $requestContext  = $serviceLocator->get('RouterRequestContext');
        $routerOptions   = array();

        $logger = $serviceLocator->has('logger') ? $serviceLocator->get('Logger') : null;

        $router = new Router($requestContext, $routeCollection, $routerOptions, $logger);

        // @todo - consider making a base router class, and then have a ModuleRouterFactory to pull module routes
        // @todo - find a way to set routes on this after we instantiate this factory

        // @todo - let you add new routes on demand and call $router->setRouteCollection()
        return $router;
    }
1259093
protected function addPluginsRoutesCollection()
    {
        $routes = new RouteCollection();

        foreach ($this->plugins as $plugin) {
            if (!$plugin->exists()) {
                throw PluginNotFoundException::createPluginRouteNotFound($plugin);
            }

            $routes->addCollection(
                $this->addPluginRoutesCollection($plugin)
            );
        }

        return $routes;
    }
144245
public function collection($namespace)
    {
        if (!class_exists($namespace)) {
            throw new InvalidRouterCollectionException('Route Collection Class $namespace doesn\'t exists');
        }

        $routeCollection = $this->getContainer()->make($namespace);

        return $routeCollection->setRouter($this);
    }
671915
private function getProtectedRoutes()
    {
        $protected = new Collection();
        $routes = RouteList::instance()->getRoutes();

        foreach ($routes as $route) {
            if ($route['middleware']->has('acl') || $route['middleware']->search('acl', true) !== false) {
                $protected->put($route['resource'], new Collection($route));
            }
        }

        return $protected;
    }
1207469
public function getRoutes()
    {
        $results = array();

        foreach ($this->routes as $route) {
            if ($route->getActionName() != 'Closure') {
                $results[] = $this->getRouteInformation($route);
            }
        }

        return Collection::make(array_filter($results));
    }
998082
public function collectRoutes()
    {
        $routes = [];

        foreach($this->getCollectors() as $collector) {
            $routes = array_merge($routes, $collector->collectRoutes());
        }

        return $routes;
    }
1181886
public function populateCollection(RouteCollection $routes): RouteCollection
    {
        foreach ($this->items as $route) {
            if ($route instanceof self) {
                $route->populateCollection($routes);
            } else {
                $routes->add(...$route);
            }
        }

        return $routes;
    }
391964
public function getRouteCollector(){
        if(null === $this->routeCollector){
            $this->routeCollector   = new RouteCollector();
            $resolver               = new Controller\ControllerResolver(
                $this,
                new \Doctrine\Common\Annotations\AnnotationReader(null)
            );

            foreach($this->bundles as $bundle){
                foreach($bundle->getControllers() as $controller){
                    foreach($resolver->getRoutes($controller) as $route){
                        $this->routeCollector->add($route);
                    }
                }
            }
        }

        return $this->routeCollector;
    }
1212816
public function load($resource, $type = null): RouteCollection
    {
        if ($this->loaded) {
            throw new \RuntimeException('Do not add the "extra" loader twice.', 1500587713);
        }

        $routes = new RouteCollection();
        $this->addModuleRoutes($routes);

        $this->loaded = true;

        return $routes;
    }
875352
protected function configureRoutes(RouteCollection $collection)
    {
        parent::configureRoutes($collection);

        $collection->add('moveUp', $this->getRouterIdParameter() . '/move-up');
        $collection->add('moveDown', $this->getRouterIdParameter() . '/move-down');
    }
1236941
public function configure(ResourceRouteCollectionInterface $resourceRouteCollection
    ): ResourceRouteCollectionInterface
    {
        $resourceRouteCollection
            ->addGet(CompaniesRestApiConfig::ACTION_COMPANIES_GET, true)
            ->addPatch(CompaniesRestApiConfig::ACTION_COMPANIES_PATCH, true)
            ->addPost(CompaniesRestApiConfig::ACTION_COMPANIES_POST, true);

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

        return self::$instance;
    }
298984
protected function localizeCollection(array $prefixes, RouteCollection $collection)
    {
        $removeRoutes = array();
        $newRoutes = new RouteCollection();
        foreach ($collection->all() as $name => $route) {
            $routeLocale = $route->getDefault(self::LOCALE_PARAM);
            if ($routeLocale !== null) {
                if (!isset($prefixes[$routeLocale])) {
                    throw new MissingRouteLocaleException(sprintf('Route `%s`: No prefix found for locale "%s".', $name, $routeLocale));
                }
                $route->setPath('/' . $prefixes[$routeLocale] . $route->getPath());
                continue;
            }
            // No locale found for the route so localize the route
            $removeRoutes[] = $name;
            foreach ($prefixes as $locale => $prefix) {
                /** @var \Symfony\Component\Routing\Route $localeRoute */
                $localeRoute = clone $route;
                $localeRoute->setPath('/' . $prefix . $route->getPath());
                $localeRoute->setDefault(self::LOCALE_PARAM, $locale);
                $newRoutes->add(
                    $this->routeNameInflector->inflect($name, $locale),
                    $localeRoute
                );
            }
        }
        $collection->remove($removeRoutes);
        $collection->addCollection($newRoutes);
    }
318291
public function addCollection($key, RouteCollection $routes, $prefix = null)
    {
        $this->routes[$key] = new RouteCollectionUrlGenerator(
            $this->app->url($prefix),
            $routes
        );

        return $this;
    }
1356667
private function resolveParameters(RouteCollection $collection)
    {
        foreach ($collection as $route) {
            foreach ($route->getDefaults() as $name => $value) {
                $route->setDefault($name, $this->resolve($value));
            }

            foreach ($route->getRequirements() as $name => $value) {
                $route->setRequirement($name, $this->resolve($value));
            }

            $route->setPath($this->resolve($route->getPath()));
            $route->setHost($this->resolve($route->getHost()));

            $schemes = [];
            foreach ($route->getSchemes() as $scheme) {
                $schemes = array_merge($schemes, explode('|', $this->resolve($scheme)));
            }
            $route->setSchemes($schemes);

            $methods = [];
            foreach ($route->getMethods() as $method) {
                $methods = array_merge($methods, explode('|', $this->resolve($method)));
            }
            $route->setMethods($methods);
            $route->setCondition($this->resolve($route->getCondition()));
        }
    }
689237
public function getRouteCollection()
    {
        if (null === $this->routeCollection) {
            $this->routeCollection = $this
                ->routeDocumentCollectionToRouteCollectionTransformer
                ->transform($this->routeDocumentRepository->findAll());
        }

        return $this->routeCollection;
    }