Loads a resource.

@param mixed  $resource The resource
@param string $type     The resource type
@return array
@suppress PhanUndeclaredClassCatch
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 [];
        }
    }
1034663
public function supports($resource, $type = null): bool
    {
        \assert('is_string($resource) && ($type === null || is_string($type))');
        return $this->parser->supports(pathinfo($resource, PATHINFO_EXTENSION));
    }
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;
    }
1314448
public function import($resource, $type = null)
    {
        return $this->resolve($resource, $type)->load($resource, $type);
    }
306289
public function load($resource, $type = null)
    {
        $collection = $this->loader->load($resource, $type);

        foreach ($collection->all() as $route) {
            if ('https' === $route->getRequirement('_scheme')) {
                $requirements = $route->getRequirements();
                unset($requirements['_scheme']);
                $route->setRequirements($requirements);
            }
        }

        return $collection;
    }
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;
    }
1082056
public function load($resource, $type = null)
    {
        $collection = new RouteCollection();
        
        foreach ($this->routes as $resource) {
            $collection->addCollection(
                  $this->import($resource, NULL)
                  );
        }
        
        return $collection;
    }
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;
    }
618873
public function deserialize($data, Resource $resource = null)
    {
        if (empty($resource)) {
            $resource = new Resource();
        }
        if (isset($data['resourceType']) && isset($data['resourceType']['name'])) {
            $resourceType = $this->resourceTypeRepo->findOneBy(['name' => $data['resourceType']['name']]);
            $resource->setResourceType($resourceType);
        }
        if (isset($data['name'])) {
            $resource->setName($data['name']);
        }
        if (isset($data['maxTimeReservation'])) {
            $resource->setMaxTimeReservation($data['maxTimeReservation']);
        }
        if (isset($data['description'])) {
            $resource->setDescription($data['description']);
        }
        if (isset($data['localization'])) {
            $resource->setLocalisation($data['localization']);
        }
        if (isset($data['quantity'])) {
            $resource->setQuantity($data['quantity']);
        }
        if (isset($data['color'])) {
            $resource->setColor($data['color']);
        }
        if (isset($data['organizations'])) {
            $this->deserializeOrganizations($resource, $data['organizations']);
        }

        return $resource;
    }
155444
protected function loadTemplateAttributes($resource, \DOMXPath $xpath, $type)
    {
        if ('page' === $type || 'home' === $type) {
            $result = [
                'key' => $this->getValueFromXPath('/x:template/x:key', $xpath),
                'view' => $this->getValueFromXPath('/x:template/x:view', $xpath),
                'controller' => $this->getValueFromXPath('/x:template/x:controller', $xpath),
                'internal' => $this->getValueFromXPath('/x:template/x:internal', $xpath),
                'cacheLifetime' => $this->loadCacheLifetime('/x:template/x:cacheLifetime', $xpath),
                'tags' => $this->loadStructureTags('/x:template/x:tag', $xpath),
                'areas' => $this->loadStructureAreas('/x:template/x:areas/x:area', $xpath),
                'meta' => $this->loadMeta('/x:template/x:meta/x:*', $xpath),
            ];

            $result = array_filter(
                $result,
                function($value) {
                    return null !== $value;
                }
            );

            foreach (['key', 'view', 'controller', 'cacheLifetime'] as $requiredProperty) {
                if (!isset($result[$requiredProperty])) {
                    throw new InvalidXmlException(
                        $type,
                        sprintf(
                            'Property "%s" is required in XML template file "%s"',
                            $requiredProperty,
                            $resource
                        )
                    );
                }
            }
        } else {
            $result = [
                'key' => $this->getValueFromXPath('/x:template/x:key', $xpath),
                'view' => $this->getValueFromXPath('/x:template/x:view', $xpath),
                'controller' => $this->getValueFromXPath('/x:template/x:controller', $xpath),
                'cacheLifetime' => $this->loadCacheLifetime('/x:template/x:cacheLifetime', $xpath),
                'tags' => $this->loadStructureTags('/x:template/x:tag', $xpath),
                'areas' => $this->loadStructureAreas('/x:template/x:areas/x:area', $xpath),
                'meta' => $this->loadMeta('/x:template/x:meta/x:*', $xpath),
            ];

            $result = array_filter(
                $result,
                function($value) {
                    return null !== $value;
                }
            );

            if (count($result) < 1) {
                throw new InvalidXmlException($result['key']);
            }
        }

        return $result;
    }
839787
public static function load(string $file, ?string $type = null) : array
    {
        if (isset($type))
        {
            if (isset(self::$classMap[$type]))
            {
                $class = self::$classMap[$type];

                $data = $class::load($file);
            }
            else
            {
                throw new Exception(
                    "There is no registered handler for the specified type "
                    .$type
                );
            }
        }
        else
        {
            self::registerSymfonyYaml();

            foreach (self::$classMap as $ext => $class)
            {
                if (preg_match('/[.]'.preg_quote($ext, '/').'$/i', $file))
                {
                    $data = $class::load($file);
                    break;
                }
            }
        }

        if ( ! isset($data))
        {
            throw new OptionLoaderException(
                "File $file does not appear to be valid"
            );
        }

        return $data;
    }
704481
public function getResolverForResource($resource, $type = null){
		if(is_string($resource) && $resource[0] === '/'){
			$dir = dirname($resource);
			$resolver = $this->getResolverForPath($dir);
		}else{
			$resolver = $this->getResolver();
		}
		return $resolver;
	}
956457
public function import($resource, $prefix = '/', $type = null)
    {
        /** @var RouteCollection[] $collections */
        $collections = $this->load($resource, $type);

        // create a builder from the RouteCollection
        $builder = $this->createBuilder();

        foreach ($collections as $collection) {
            if (null === $collection) {
                continue;
            }

            foreach ($collection->all() as $name => $route) {
                $builder->addRoute($route, $name);
            }

            foreach ($collection->getResources() as $resource) {
                $builder->addResource($resource);
            }
        }

        // mount into this builder
        $this->mount($prefix, $builder);

        return $builder;
    }
331097
public function load($resource, $type = null)
    {
        if ($this->loaded) {
            throw new \RuntimeException('Do not add this loader twice');
        }

        $routes = new RouteCollection();

        $routes->addCollection(
            $this->addPluginsRoutesCollection()
        );

        $this->loaded = true;

        return $routes;
    }
1371864
public function resolve(string $type, string $resource, array $parameters = [], $version = null)
    {
        $version = $version ?? $this->version;

        if (str_contains($resource, '.')) {
            list($resource, $related) = explode('.', $resource);
            $resourceDefinition = $this->loadRelatedDefinition($version, $resource, $related, $type);
        } else {
            $resourceDefinition = $this->loadDefinition($version, $resource, $type);
        }

        return $this->app->make($resourceDefinition, $parameters);
    }
1131429
public static function getResourceParser($resource)
    {
        if(self::$_resourceLoader) {
            $type = preg_replace("/[^A-Za-z0-9_]/", " ", get_resource_type($resource));
            $type = str_replace(" ","", ucwords($type));
            return self::$_resourceLoader->load($type);
        }
        return false;
    }
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;
    }