Load routes for all services tagged with graviton.rest

@param string $resource unused
@param string $type     unused

@return RouteCollection
3501
public function load($resource, $type = null)
    {
        if (true === $this->loaded) {
            throw new \RuntimeException('Do not add the "graviton.rest.routing.loader" loader twice');
        }

        foreach ($this->services as $service => $serviceConfig) {
            $this->loadService($service, $serviceConfig);
        }

        $this->loaded = true;

        return $this->routes;
    }
1253385
public function load($resource, $type = null)
    {
        if (true === $this->loaded) {
            throw new \RuntimeException('Do not add the "shuwee_admin_extra" loader twice');
        }

        $routeCollection = new RouteCollection();
        foreach ($this->adminManager->getAdmins() as $alias => $admin) {
            // List
            $routeCollection->add(
                $this->routingHelper->getRouteName($admin, 'index'),
                $this->routingHelper->getRoute($admin, 'index', [], true)
            );

            // Create
            $routeCollection->add(
                $this->routingHelper->getRouteName($admin, 'create'),
                $this->routingHelper->getRoute($admin, 'create')
            );

            // Update
            $routeCollection->add(
                $this->routingHelper->getRouteName($admin, 'update'),
                $this->routingHelper->getRoute($admin, 'update', ['id'])
            );

            // Delete
            $routeCollection->add(
                $this->routingHelper->getRouteName($admin, 'delete'),
                $this->routingHelper->getRoute($admin, 'delete', ['id'])
            );

            // Toggle field
            $routeCollection->add(
                $this->routingHelper->getRouteName($admin, 'toggle'),
                $this->routingHelper->getRoute($admin, 'toggle', ['id', 'field', 'token']
                )
            );
        }

        $this->loaded = true;

        return $routeCollection;
    }
163092
public function load($resource, $type = null)
    {
        $collection = new RouteCollection();

        if ($this->components != null) {
            foreach ($this->components as $componentName => $component) {
                if (!isset($component['bundle'])) {
                    continue;
                }

                $bundleClassName = preg_replace('/^.*\\\/', '', $component['bundle']);
                $resource = '@' . $bundleClassName . '/Resources/config/routing.yml';
                $type = 'yaml';

                /** @var RouteCollection $importedRoutes */
                $importedRoutes = $this->import($resource, $type);

                foreach ($importedRoutes as $route) {
                    /** @var Route $route */
                    if (!strstr($route->getPath(), $componentName)) {
                        $route->setPath('/'. $componentName . $route->getPath());
                    }
                }

                $collection->addCollection($importedRoutes);
            }
        }

        return $collection;
    }
498559
public function loadFlat($resource, $type = null, $require = false)
    {
        return ArrayUtil::flatten($this->load($resource, $type, $require));
    }
281755
public function resolve(string $resource, string $type = ''): string
    {
        if (! $this->hasLocalPath()) {
            return $resource;
        }
        if ('' === $type) {
            $type = $this->obtainTypeFromUrl($resource);
        } else {
            $type = strtoupper($type);
        }
        $retriever = $this->newRetriever($type);
        if (null === $retriever) {
            throw new \RuntimeException("Unable to handle the resource (Type: $type) $resource");
        }
        $local = $retriever->buildPath($resource);
        if (! file_exists($local)) {
            $retriever->retrieve($resource);
        }
        return $local;
    }
193782
public function load($resource, $type = null): array
    {
        try {
            $path = $this->locator->locate($resource);
            $file = $this->filesystem->openFile($path);
            $configValues = $this->yamlParser->parse($file->getContents());

            return $configValues;
        } catch (FileLocatorFileNotFoundException $error) {
            return [];
        }
    }
588335
public function load($resource)
    {
        if ($this->cacher->check($resource)) {
            return $this->cacher->retrieve($resource);
        }

        $this->reader->open($resource);

        /** @var \Yosmanyga\Validation\Resource\Definition\ObjectDefinition[] $definitions */
        $definitions = [];
        /** @var \Yosmanyga\Validation\Validator\ObjectValidator[] $validators */
        $validators = [];
        while ($data = $this->reader->current()) {
            /** @var \Yosmanyga\Validation\Resource\Definition\ObjectDefinition $definition */
            $definition = $this->normalizer->normalize($data, $resource);

            $definitions[$definition->class] = $definition;
            $validators[$definition->class] = $this->compiler->compile($definition);

            $this->reader->next();
        }

        $validators = $this->fillObjectValidators($definitions, $validators);

        $this->cacher->store($validators, $resource);

        return $validators;
    }
1138966
private function load($resource, string $type = null): array
    {
        if (null === $this->loader) {
            throw new \BadMethodCallException('Cannot import other routing resources: you must pass a LoaderInterface when constructing RouteCollectionBuilder.');
        }

        if ($this->loader->supports($resource, $type)) {
            $collections = $this->loader->load($resource, $type);

            return \is_array($collections) ? $collections : [$collections];
        }

        if (null === $resolver = $this->loader->getResolver()) {
            throw new LoaderLoadException($resource, null, null, null, $type);
        }

        if (false === $loader = $resolver->resolve($resource, $type)) {
            throw new LoaderLoadException($resource, null, null, null, $type);
        }

        $collections = $loader->load($resource, $type);

        return \is_array($collections) ? $collections : [$collections];
    }
235957
public static function fromResource(Resource $resource)
    {
        if (isset($resource->query['with_billets'])) {
            return static::withBillets($resource);
        }
        return parent::fromResource($resource);
    }
843956
public function supports($resource, $type = null){
		$resolver = $this->getResolverForResource($resource, $type);
		return $resolver->resolve($resource, $type) !== false;
	}
1086796
public function load($resource, $type = null)
    {
        if ($this->loaded) {
            throw new RuntimeException('Do not add this loader twice');
        }

        $routes = new RouteCollection();

        $routes->add($this->inputControllerRouteName, new Route($this->inputResizeControllerRoute, [
            '_controller' => 'elcodi.controller.metric_input:addEntryAction',
        ]));

        $this->loaded = true;

        return $routes;
    }
95651
public function load($file, $type = null)
    {
        $path = $this->locator->locate($file);

        $collection = new RouteCollection();
        if ($class = $this->findClass($path)) {
            // module file resource
            $collection->addResource(new FileResource($path));

            // module instance
            $module = $this->moduleManager->get($class);

            // routes prefixes
            $routeNamePrefix = $module->getRouteNamePrefix();
            $routePatternPrefix = $module->getRoutePatternPrefix();

            // route actions
            foreach ($module->getRouteActions() as $action) {
                // action file resource
                $reflection = new \ReflectionObject($action);
                $collection->addResource(new FileResource($reflection->getFileName()));

                // name (module prefix + action suffix)
                $name = $routeNamePrefix.$action->getRouteName();
                // pattern (module prefix + action suffix)
                if ('/' === $action->getRoutePattern() && '' !== $routePatternPrefix) {
                    $pattern = $routePatternPrefix;
                } else {
                    $pattern = $routePatternPrefix.$action->getRoutePattern();
                }
                // defaults (action defaults + defaults needed to execute)
                $defaults = array_merge($action->getRouteDefaults(), array(
                    '_controller' => 'PablodipModuleBundle:Module:execute',
                    '_module.module' => $class,
                    '_module.action' => $action->getName(),
                ));
                // requirements (just from the action)
                $requirements = $action->getRouteRequirements();
                // options (from the action)
                $options = $action->getRouteOptions();

                $collection->add($name, new Route($pattern, $defaults, $requirements, $options));
            }
        }

        return $collection;
    }
921109
public function load($resource, $type = null)
    {
        $path = $this->locator->locate($resource);
        $this->container->addResource(new FileResource($path));

        $file = new JsonFile($path);
        $content = $file->read();
        $extension = pathinfo($resource, PATHINFO_FILENAME);

        if (array_key_exists('parameters', $content)) {
            foreach ($content['parameters'] as $name => $parameter) {
                $this->container->setParameter($name, $parameter);
            }

            unset($content['parameters']);
        }

        if (array_key_exists('imports', $content)) {
            foreach ($content['imports'] as $import) {
                $importFilename = $import;
                if (!Path::isAbsolute($importFilename)) {
                    $importFilename = Path::join([dirname($path), $import]);
                }

                $this->import($importFilename, null, false, $file);
            }

            unset($content['imports']);
        }

        $this->container->loadFromExtension($extension, $content);
    }
399234
public function load($resource, $type = null) 
    {
        $path = $this->locator->locate($resource);
        
        if (!stream_is_local($path)) {
            throw new \InvalidArgumentException(sprintf('This is not a local file "%s".', $path));
        }

        if (!file_exists($path)) {
            throw new \InvalidArgumentException(sprintf('File "%s" not found.', $path));
        }

        $returnArray = include $path;
        
        if(false === is_array($returnArray)) {
            throw ConfigException::configNotArray($path);
        }
        
        $this->loaded[$resource] = $path;
        
        return $returnArray;
    }
159630
final public function load(string $namespace, string $resource): PrototypeConfigurator
    {
        $this->__destruct();

        return $this->parent->load($namespace, $resource);
    }
450649
protected function loadResource($resource, $required)
    {
        foreach ($this->loaders as $loader) {
            if (!$loader->supports($resource)) {
                continue;
            }

            try {
                return $loader->load($resource);
            } catch (ResourceNotFoundException $e) {
                if ($required) {
                    throw $e;
                }

                return [];
            }
        }

        throw new ResourceException(sprintf('There is no configuration loader available to load the resource "%s"', $resource));
    }
792333
public function load($domainName, $type = null)
    {
        $path = 'routing.yml';
      
        if(!$this->container['isCMS'])
        {
          
            $site = $this->container['em']->getRepository('\Aspi\Framework\Entity\Site')->getByDomain($domainName);
        }
        else
        {
          
            $site = $this->container['em']->getRepository('\Aspi\CMS\Framework\Entity\Site')->getByDomain($domainName);
            $this->container['theme'] = $site['name'];
            $this->container['hook'] = $site['hook'];
     
        }
        if(!$site)
        {
            throw new \InvalidArgumentException(sprintf('File not found for domain "%s".', $domainName));
        }
        if (null === $this->yamlParser) {
            $this->yamlParser = new YamlParser();
        }
        try {
$parsedString =<<<EOT
homepage:
    locales:  { en: "/welcome", fr: "/bienvenue", de: "/willkommen" }
    defaults: { _controller: '\Controller\Home::Index'}

page:
    locales:  { en: "/page/", fr: "/bienvenue", de: "/willkommen" }
    defaults: { _controller: '\Controller\Home::Index'}

loginpage:
    locales:  { en: "/login", fr: "/se-connecter"}    
    defaults: { _controller: '\Controller\Home::Login' }

admin:
    path:     /admin
    defaults: { _controller: 'App\Controller\DefaultController::default' }
EOT;

            $parsedString .=$site['routing'];
            $parsedConfig = $this->yamlParser->parse($parsedString);
        } catch (ParseException $e) {
            throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $path), 0, $e);
        }
        $collection = new RouteCollection();
        // empty file
        if (null === $parsedConfig) {
            return $collection;
        }
        // not an array
        if (!is_array($parsedConfig)) {
            throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $path));
        }
        foreach ($parsedConfig as $name => $config) {
            if (isset($config['pattern'])) {
                if (isset($config['path'])) {
                    throw new \InvalidArgumentException(sprintf('The file "%s" cannot define both a "path" and a "pattern" attribute. Use only "path".', $path));
                }
                $config['path'] = $config['pattern'];
                unset($config['pattern']);
            }
            $this->validate($config, $name, $path);
            if (isset($config['resource'])) {
                $this->parseImport($collection, $config, $path, $file);
            } else {
                $this->parseRoute($collection, $name, $config, $path);
            }
        }
        return $collection;
    }