Loads the routes into a collection.

Loads the resources from cache if the cache is still valid, or re-loads
and re-creates the cache if neccessary.

@return RouteCollectionInterface
483791
public function load(RouteLoaderInterface $loader, $forceValidate = false)
    {
        if (!$this->isValid($forceValidate)) {
            $loader->addListener($this);
            $this->doLoadResources($loader, $forceValidate);
            $loader->removeListener($this);
        }

        return $this->storage->read();
    }
897008
public function load(CachedCollectionInterface $routes)
    {
        if (!is_file($file = $this->getFilePath($routes)) || filemtime($file) < $routes->getTimestamp()) {
            $this->dumpMap($routes, $file);
        }

        return $this->loadMap($file);
    }
735080
public function loadRoutesCache(): bool
    {
        if (!$this->isCacheEnable()) {
            return false;
        }

        $file = $this->cacheFile;
        if (!$file || !\file_exists($file)) {
            return false;
        }

        // load routes
        $map = require $file;
        $this->routeCounter = 0;
        $staticRoutes = $regularRoutes = $vagueRoutes = [];

        foreach ($map['staticRoutes'] as $key => $info) {
            $this->routeCounter++;
            $staticRoutes[$key] = Route::createFromArray($info);
        }

        foreach ($map['regularRoutes'] as $key => $routes) {
            foreach ($routes as $info) {
                $this->routeCounter++;
                $regularRoutes[$key][] = Route::createFromArray($info);
            }
        }

        foreach ($map['vagueRoutes'] as $key => $routes) {
            foreach ($routes as $info) {
                $this->routeCounter++;
                $vagueRoutes[$key][] = Route::createFromArray($info);
            }
        }

        $this->staticRoutes = $staticRoutes;
        $this->regularRoutes = $regularRoutes;
        $this->vagueRoutes = $vagueRoutes;
        $this->cacheLoaded = true;

        return true;
    }
885060
public function loadRoutes()
    {
        $packageName = $this->getPackageName();

        foreach (Config::get('amethyst.'.$packageName.'.http') as $groupName => $group) {
            foreach ($group as $configName => $config) {
                if (Arr::get($config, 'enabled')) {
                    Router::group($groupName, Arr::get($config, 'router'), function ($router) use ($config) {
                        $controller = Arr::get($config, 'controller');

                        $reflection = new \ReflectionClass($controller);

                        if ($reflection->hasMethod('index')) {
                            $router->get('/', ['as' => 'index', 'uses' => $controller.'@index']);
                        }

                        if ($reflection->hasMethod('store')) {
                            $router->put('/', ['as' => 'store', 'uses' => $controller.'@store']);
                        }

                        if ($reflection->hasMethod('erase')) {
                            $router->delete('/', ['as' => 'erase', 'uses' => $controller.'@erase']);
                        }

                        if ($reflection->hasMethod('create')) {
                            $router->post('/', ['as' => 'create', 'uses' => $controller.'@create']);
                        }

                        if ($reflection->hasMethod('update')) {
                            $router->put('/{id}', ['as' => 'update', 'uses' => $controller.'@update']);
                        }

                        if ($reflection->hasMethod('remove')) {
                            $router->delete('/{id}', ['as' => 'remove', 'uses' => $controller.'@remove']);
                        }

                        if ($reflection->hasMethod('show')) {
                            $router->get('/{id}', ['as' => 'show', 'uses' => $controller.'@show']);
                        }
                    });
                }
            }
        }
    }
1321703
private function doLoadResources(RouteLoaderInterface $loader, $forceValidate)
    {
        $collection = [];

        foreach ($this->resources->all() as $i => $resource) {
            // dont't add the prmary resource to
            $this->current = (string)$resource;

            if ($loaded = $loader->loadRoutes($resource)) {
                $collection[] = $loaded->all();
            }
        }

        $routes = call_user_func_array('array_merge', $collection);

        if ($this->isDebugging() || $forceValidate) {
            $this->writeManifests();
        }

        $this->current = null;
        $this->storage->write(new Routes($routes));
    }
1225855
public function load($resource, $type = null)
    {
        $collection = new SymfonyRouteCollection();
        try{
            $results = $this->manager->findAllAlias();
        }catch (\Exception $e){
            return $collection;
        }
        foreach ($results as $metatag) {
            if (is_array($metatag['pathinfo'])) {
                $pathinfo = $metatag['pathinfo'];
            } else {
                $pathinfo = @unserialize($metatag['pathinfo']);
            }
            if (!is_array($pathinfo) || !isset($pathinfo['_route']) || !isset($metatag['alias'])) {
                continue;
            }
            $oldroute = $pathinfo['_route'];

            //add defaults to routealias
            if (isset($pathinfo['__defaults']) && is_array($pathinfo['__defaults'])) {
                foreach ($pathinfo['__defaults'] as $key => $value) {
                    if (strpos($key, '_') !== 0) {
                        $metatag['alias'] .= '-{'.$key.'}';
                    }
                }
            }
            $route = new Route($metatag['alias'], $pathinfo, array(), array());
            $collection->add(self::getRouteName($oldroute, $pathinfo), $route);
        }

        return $collection;
    }
721943
protected function buildRouteCollection()
    {
        if (Cache::enabled() && $this->cacheConfig !== null) {
            return Cache::remember(static::ROUTE_COLLECTION_CACHE_KEY, function () {
                return $this->prepareRouteCollection();
            }, $this->cacheConfig);
        }

        return $this->prepareRouteCollection();
    }
980513
public function routes() {
    $collection = new RouteCollection();

    if ($this->moduleHandler->moduleExists('views_bulk_operations')) {
      $route = new Route(
        '/node/{node}/all-enrollments/configure-action',
        [
          '_form' => '\Drupal\social_event_managers\Form\SocialEventManagementViewsBulkOperationsConfigureAction',
          '_title' => 'Configure action',
          'view_id' => 'event_manage_enrollments',
          'display_id' => 'page_manage_enrollments',
        ],
        [
          '_views_bulk_operation_access' => 'TRUE',
        ]
      );
      $collection->add('social_event_managers.vbo.execute_configurable', $route);

      $route = new Route(
        '/node/{node}/all-enrollments/confirm-action',
        [
          '_form' => '\Drupal\social_event_managers\Form\SocialEventManagersViewsBulkOperationsConfirmAction',
          '_title' => 'Confirm action',
          'view_id' => 'event_manage_enrollments',
          'display_id' => 'page_manage_enrollments',
        ],
        [
          '_views_bulk_operation_access' => 'TRUE',
        ]
      );
      $collection->add('social_event_managers.vbo.confirm', $route);
    }

    return $collection;
  }
594636
public function load($resource, $type = null)
    {
        $collection = new RouteCollection();
        $controllers = $this->controllerFinder->getAllControllerFromResource($resource);
        /** @var \ReflectionClass $controller */
        foreach ($controllers as $controller) {
            if (!$controller) {
                //bugfix for windows OS
                continue;
            }

            if ($controller->isSubclassOf(CrudController::class) || $controller->getName() === HomeController::class || $controller->getName() === ProfileController::class) {
                $this->registerRoute($collection, $controller);
            } else {
                $collection->addCollection(parent::load($resource, 'annotation'));
            }
        }

        return $collection;
    }
1219129
public function create(RouteCollection $routes): Tree
    {
        $routesArray = $routes->all();

        $routesPaths = array_map(function (Route $route) {
            return $this->serializer->serialize($route->getPath());
        }, $routesArray);

        $tree = new Tree();

        /** @var RoutePath[] $pathArray */
        foreach ($routesPaths as $index => $pathArray) {
            $route = $routesArray[$index];

            /** @var TreeNode $treeNode */
            $treeNode = $tree;

            foreach ($pathArray as $path) {
                $treeNode = $this->addPathPartToTree($treeNode, $path, $route, $index);
            }
        }

        return $tree;
    }
490341
private function loadRouteRules()
    {
        foreach ($this->rules['routeRules'] as $routeAlias => $routeRuleSets) {
            $resourceId = call_user_func_array($this->config['routeResourceGenerator'], [$routeAlias]);
            $this->acl->addResource(new Resource($resourceId));
            foreach ($routeRuleSets as $ruleSet) {
                $this->enforceRuleset($ruleSet, ['resources' => $resourceId, 'privileges' => $this->config['routePrivilege']]);
            }
        }
    }
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;
    }
466221
private function loadRoutes()
    {
        $cacheName = $this->mode . '_Phavour_Application_routes';
        if (false != ($routes = $this->cache->get($cacheName))) {
            // @codeCoverageIgnoreStart
            $this->routes = $routes;
            return;
            // @codeCoverageIgnoreEnd
        }

        $routes = array();
        foreach ($this->packagesMetadata as $package) {
            try {
                $finder = new FromArray($package['route_path']);
                $proposedRoutes = $finder->getArray();
                if (is_array($proposedRoutes)) {
                    foreach ($proposedRoutes as $key => $routeDetails) {
                        if (!array_key_exists('package', $routeDetails)) {
                            $proposedRoutes[$key]['package'] = $package['package_name'];
                        }
                        $proposedRoutes[$key]['package'] = $package['package_name'];
                    }
                    $routes = array_merge($routes, $proposedRoutes);
                }
            } catch (\Exception $e) {
                // Package doesn't have routes
            }
        }

        try {
            $finder = new FromArray(
                $this->appDirectory . DIRECTORY_SEPARATOR . 'res' . DIRECTORY_SEPARATOR . 'routes.php'
            );
            $appRoutes = $finder->getArray();
            if (is_array($appRoutes)) {
                foreach ($appRoutes as $routeDetails) {
                    // @codeCoverageIgnoreStart
                    if (!array_key_exists('package', $routeDetails)) {
                        throw new RouteMissingPackageNameException();
                    }
                    // @codeCoverageIgnoreEnd
                }
                $routes = array_merge($routes, $appRoutes);
            }
        } catch (\Exception $e) {
            // No route overrides set
        }

        $this->routes = $routes;
        $this->cache->set($cacheName, $this->routes, 86400);
    }
714018
public function flush()
    {
        if (null === $this->routesFactory) {
            $routes = new RouteCollection();
        } else {
            $routes = $this->routesFactory;
        }

        return $this->doFlush('', $routes);
    }
1140390
public function createRoutes()
    {
        if( empty( $this->routes ) )
        {
            // Check if route caching is enabled and if APC is available
            $isRouteCacheEnabled = eZINI::instance( 'rest.ini' )->variable( 'CacheSettings', 'RouteApcCache' ) === 'enabled';
            if( $isRouteCacheEnabled && ezcBaseFeatures::hasExtensionSupport( 'apc' ) )
            {
                $this->routes = $this->getCachedRoutes();
            }
            else
            {
                $this->routes = $this->doCreateRoutes();
            }
        }

        return $this->routes;
    }
957370
protected function getFreshApplicationRoutes()
    {
        return tap($this->getFreshApplication()['router']->getRoutes(), function ($routes) {
            /** @var RouteCollection $routes */
            $routes->refreshNameLookups();
            $routes->refreshActionLookups();
        });
    }
1300044
public function loadRouteCollection($source = null)
    {
        $collection = new RouteCollection();

        $routes = $this->loadResource($source);

        foreach ($routes as $name => $route) {
            $collection->add($name, $this->parseRoute($route));
        }

        return $collection;
    }