Loads a resource.

@param mixed $resource The resource
@param string|null $type The resource type or null if unknown

@return array
@throws \Exception If something went wrong
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;
    }
414566
protected function useHeadersFromType($type=null)
	{
		$defaultHeaders['json'] = array(
			'Accept:application/json',
			'Content-Type:application/json',
		);
		$defaultHeaders['xml'] = array(
			'Accept:application/xml',
			'Content-Type:application/xml',
		);
		$defaultHeaders['custom'] = null;
		if(!isset($type) OR !isset($defaultHeaders[$type]))
		{
			$this->resource = 'custom';
			return $defaultHeaders[$this->defaultResource];
		}
		$this->resource = $type;
		return $defaultHeaders[$type];
	}
1082056
public function load($resource, $type = null)
    {
        $collection = new RouteCollection();
        
        foreach ($this->routes as $resource) {
            $collection->addCollection(
                  $this->import($resource, NULL)
                  );
        }
        
        return $collection;
    }
681800
public function execute($resource = null)
    {
        $this->populateCDNResources();

        foreach ($this->cdnResources as $cdnResource) {
            if (false !== strpos($cdnResource['cname'], $resource)) {
                $url = sprintf($this->url . '?login=%s&passwd=%s&cdn_id=%d&period=4&http_status[]=cached&http_status[]=noncached',
                    $this->login,
                    $this->password,
                    $cdnResource['id']
                );

                $response = $this->client->get($url);

                $responseData = json_decode($response->getBody()->getContents(), true);

                return $responseData['logs'];
            }
        }

        return [];
    }
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;
    }
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;
    }
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;
    }
493837
public function load($resource, $type = null): RouteCollection
    {
        $resource = (string)$resource;
        if (in_array($resource, $this->descriptions)) {
            throw new \RuntimeException("Resource '$resource' was already loaded");
        }

        $description = $this->repository->get($resource);

        $routes           = new RouteCollection();
        $router           = $description->getExtension('router') ?: "$this->typeName.controller";
        $routerController = $description->getExtension('router-controller');

        foreach ($description->getPaths() as $pathItem) {
            $relativePath = ltrim($pathItem->getPath(), '/');
            $resourceName = strpos($relativePath, '/')
                ? substr($relativePath, 0, strpos($relativePath, '/'))
                : $relativePath;

            $routerController = $pathItem->getExtension('router-controller') ?: $routerController;

            foreach ($pathItem->getOperations() as $operation) {
                $controllerKey = $this->resolveControllerKey(
                    $operation,
                    $resourceName,
                    $router,
                    $routerController
                );
                $defaults      = [
                    '_controller'               => $controllerKey,
                    RequestMeta::ATTRIBUTE_URI  => $resource,
                    RequestMeta::ATTRIBUTE_PATH => $pathItem->getPath(),
                ];

                $route = new Route(
                    $pathItem->getPath(),
                    $defaults,
                    $this->resolveRequirements($operation),
                    [],
                    '',
                    $description->getSchemes()
                );
                $route->setMethods($operation->getMethod());
                $routes->add($this->createRouteId($resource, $pathItem->getPath(), $controllerKey), $route);
            }
        }

        $this->descriptions[] = $resource;

        return $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;
    }
574653
public function resolve($resource)
    {
        foreach ($this->loaders() as $loader) {
            if ($loader->supports($resource)) {
                return $loader;
            }
        }

        throw new LoaderException('No matching loader found.');
    }
169760
public function resource($name, $resource = null)
    {
        if ($resource) {
            $this->addResource($name, $resource);
        } else {
            return $this->getResource($name);
        }
    }
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);
    }
1370986
public static function createAdapterFromResource($resource)
    {
        if (is_scalar($resource) || is_array($resource)) {
            throw new Exception\InvalidArgumentException("Resource param must be a valid 'resource' link (mysqli, pdo)");
        }
        if ($resource instanceof \PDO) {
            $adapter = self::getAdapterFromPdo($resource);
        } elseif (extension_loaded('mysqli') && $resource instanceof \mysqli) {
            $adapter = new Adapter\MysqliAdapter($resource);
        } else {
            throw new Exception\InvalidArgumentException('Resource must be a valid connection link, like PDO or mysqli');
        }

        return $adapter;
    }
41604
public function import($resource)
    {
        if ($this->supports($resource)) {
            return $this->load($resource);
        }

        if (null === $res = $this->getResolver()) {
            throw LoaderException::missingLoader($resource);
        }

        try {
            $loader = $res->resolve($resource);
        } catch (LoaderException $e) {
            throw new LoaderException($e->getMessage(), $e->getCode(), $e);
        }

        $loader->load($resource);
    }
419958
public function getActionsByResource($resource)
    {
        if (!isset($this->resources[$resource])) {
            return null; // no resource found
        }

        $actions = array();
        foreach ($this->resources[$resource] as $action => $path) {
            $actions[] = $action;
        }

        return $actions;
    }
1164419
public static function load(Smarty $smarty, $type = null)
    {
        if (!isset($type)) {
            $type = $smarty->caching_type;
        }

        // try smarty's cache
        if (isset($smarty->_cacheresource_handlers[$type])) {
            return $smarty->_cacheresource_handlers[$type];
        }

        // try registered resource
        if (isset($smarty->registered_cache_resources[$type])) {
            // do not cache these instances as they may vary from instance to instance
            return $smarty->_cacheresource_handlers[$type] = $smarty->registered_cache_resources[$type];
        }
        // try sysplugins dir
        if (isset(self::$sysplugins[$type])) {
            if (!isset(self::$resources[$type])) {
                $cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($type);
                self::$resources[$type] = new $cache_resource_class();
            }

            return $smarty->_cacheresource_handlers[$type] = self::$resources[$type];
        }
        // try plugins dir
        $cache_resource_class = 'Smarty_CacheResource_' . ucfirst($type);
        if ($smarty->loadPlugin($cache_resource_class)) {
            if (!isset(self::$resources[$type])) {
                self::$resources[$type] = new $cache_resource_class();
            }

            return $smarty->_cacheresource_handlers[$type] = self::$resources[$type];
        }
        // give up
        throw new SmartyException("Unable to load cache resource '{$type}'");
    }
840754
public function loadConfig($resource, $type = null)
    {
        $this->getConfigManager()->addConfig($resource, $type);

        return $this;
    }