Loads a resource.

@param mixed $resource The resource
@param string $type     The resource type
@return \Symfony\Component\Routing\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;
    }
138452
public function load($resource, $type = null)
    {
        if (! is_file($resource)) {
            throw new InvalidArgumentException(sprintf('File "%s" is not a regular file.', $resource));
        }

        /* Checking file readability before hand to ensure getting its contents never fail. */
        if (! is_readable($resource)) {
            throw new InvalidArgumentException(sprintf('File "%s" is not readable.', $resource));
        }

        /* Explicitly reading file's content, because support for passing file names is deprecated since Symfony 2.8. */
        $content = file_get_contents($resource);
        $parsedYaml = Yaml::parse($content);

        if (! is_array($parsedYaml)) {
            throw new InvalidArgumentException(sprintf('Could not parse Yaml of file "%s"', $resource));
        }

        return $parsedYaml;
    }
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;
    }
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];
    }
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;
    }
39844
public function addResource($resource, string $type = 'file'): void
    {
        if (is_array($resource)) {
            $this->addResourceArray($resource);
            return;
        }

        if (is_string($resource)) {
            switch ($type) {
                case 'json':
                    $this->addResourceString($resource);
                    break;
                case 'file':
                    $this->addResourceFile($resource);
                    break;
                default:
                    throw new \InvalidArgumentException("Invalid resource type");
            }
        }
    }
256603
protected function _loadResource($resource) {
        return $this->cache([__METHOD__, $resource], function() use ($resource) {
            $data = $this->getLocaleBundle()->loadResource(null, $resource);

            if ($parent = $this->getParentLocale()) {
                $data = array_merge(
                    $parent->getLocaleBundle()->loadResource(null, $resource),
                    $data
                );
            }

            return $data;
        });
    }
148447
private function loadImage(string $resource)
    {
        try {
            return $this->resourceLoader->load(
                    $resource,
                    function($fileName) { return ImageSource::load($fileName); }
            );
        } catch (\Throwable $t) {
            // not allowed to throw exceptions, as we are outside any catching
            // mechanism
            trigger_error(
                    'Can not load image "' . $resource . '": ' . $t->getMessage(),
                    E_USER_ERROR
            );
            return null;
        }
    }
1221707
public function load($resource, $type = null)
    {
        $resource = (string) $resource;

        if (!is_file($resource)) {
            throw new InvalidArgumentException(sprintf('File "%s" is not a regular file.', $resource));
        }

        if (!is_readable($resource)) {
            throw new InvalidArgumentException(sprintf('File "%s" is not readable.', $resource));
        }

        $content = file_get_contents($resource);
        $decoded = @json_decode($content, true);

        if ($decoded === null) {
            throw new InvalidArgumentException(
                sprintf('File "%s" cannot be json decode (error code: %s).', $resource, json_last_error())
            );
        }

        return $decoded;
    }
669864
public static function getResource(string $type)
    {
        if (isset(self::$resources[$type])) {
            return self::$resources[$type];
        }
        $class = '\\sdopx\\resource\\' . Utils::toCamel($type) . 'Resource';
        if (class_exists($class)) {
            self::$resources[$type] = new $class();
            return self::$resources[$type];
        }
        return null;
    }
7006
public function load($resource, $type = null)
    {
        if ($this->loaded) {
            throw new \RuntimeException('Do not add this loader twice');
        }

        $collection = new RouteCollection();

        foreach ($this->container->getParameter('smart_core_cms.modules') as $moduleName => $module) {
            $resource = $module['path'].'/Resources/config/routing_admin.yml';
            if (file_exists($resource)) {
                $importedRoutes = $this->import('@'.$moduleName.'ModuleBundle/Resources/config/routing_admin.yml', 'yaml');
                $importedRoutes->addPrefix($moduleName);

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

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

        $routes = new RouteCollection();

        foreach ($this->adminRegistry->getAdmins() as $admin) {
            foreach ($admin->getActions() as $action) {
                $routes->add($action->getRouteName(), $action->getRoute());
            }
        }

        $this->loaded = true;

        return $routes;
    }
498559
public function loadFlat($resource, $type = null, $require = false)
    {
        return ArrayUtil::flatten($this->load($resource, $type, $require));
    }
110140
public function load($resource, $type = null)
    {
        if (!$resource instanceof ConfiguratorInterface) {
            throw new InvalidArgumentException('Resource must be configurator');
        }

        $this->container->addObjectResource($resource);
        $resource->load($this->container);
    }
489704
public function load($resource, $type = null)
    {
        $routes = new RouteCollection();

        $pattern = '/_pygments_bundle/style.css';
        $defaults = array(
            '_controller' => 'CypressPygmentsElephantBundle:Main:css',
        );

        $route = new Route($pattern, $defaults);
        $routes->add('pygments_bundle_style', $route);

        return $routes;
    }
498518
public function load($resource, $type = null)
    {
        $configValues = Yaml::parse(file_get_contents($resource));

        $processor = new Processor();
        $configuration = new SignalertConfiguration();
        $processedConfiguration = $processor->processConfiguration(
            $configuration,
            [$configValues]
        );

        return $processedConfiguration;
    }
159630
final public function load(string $namespace, string $resource): PrototypeConfigurator
    {
        $this->__destruct();

        return $this->parent->load($namespace, $resource);
    }