Return module resource for the given path, if specified as one.
Returns the original resource otherwise.

@param string $resource
@return ModuleResource|string The resource, or input string if not a module resource
181613
public function resolveResource($resource)
    {
        // String of the form vendor/package:resource. Excludes "http://bla" as that's an absolute URL
        if (!preg_match('#^ *(?<module>[^/: ]+/[^/: ]+) *: *(?<resource>[^ ]*)$#', $resource, $matches)) {
            return $resource;
        }
        $module = $matches['module'];
        $resource = $matches['resource'];
        $moduleObj = ModuleLoader::getModule($module);
        if (!$moduleObj) {
            throw new InvalidArgumentException("Can't find module '$module', the composer.json file may be missing from the modules installation directory");
        }
        $resourceObj = $moduleObj->getResource($resource);

        return $resourceObj;
    }
756753
public static function fromResource(ResourceInterface $resource, $path)
	{
		if ($resource instanceof FileResourceInterface) {
			return $resource;
		}
		file_put_contents($path, $resource->getStream());
		$attr = [
			'mimetype' => $resource->getMimetype(),
			'lastmodified' => $resource->getLastModified(),
			'filename' => $resource->getFilename()
		];
		return new FileResource($path, $attr);
	}
595563
public function loadResource($resource)
    {
        // If possible use our custom xliff loader, so we get metadata
        if (in_array($resource['format'], array('xliff', 'xlf'))) {
            return $this->container->get('liip.translation.xliff.loader')->load($resource['path'], $resource['locale'], $resource['domain']);
        }

        // Search for an other services
        foreach ($this->loaderIds as $serviceId => $formats) {
            if (!is_array($formats)) {
                $formats = array($formats);
            }
            foreach ($formats as $format) {
                if ($resource['format'] === $format) {
                    return $this->container->get($serviceId)->load($resource['path'], $resource['locale'], $resource['domain']);
                }
            }
        }

        throw new \RuntimeException("Not service found to load {$resource['path']}");
    }
1030537
public static function fromResource($resource) {
        $newImage = new self();
        try {
            $newImage->setResource($resource);
        } catch(\Exception $e) {
            throw new ImageException($e->getMessage(), ImageException::UnsupportedFormatException, $e);
        }
        return $newImage;
    }
76888
protected function authorizeResource($resource)
    {
        if ($this->isEditing($resource)) {
            return $this->user()->can($resource . '.update');
        }

        return $this->user()->can($resource . '.create');
    }
609593
public function getAsciiContent(string $resource): string
    {
        $file = $this->config->getAsciiContentPath($resource);

        // Disabled:
        if (null === $file) {
            return '';
        }

        // Specified by user:
        if ($this->fileSystem->exists($file)) {
            return $this->fileSystem->readFromFileInfo(new SplFileInfo($file));
        }

        // Embedded ASCII art:
        $embeddedFile = $this->getAsciiPath().$file;
        if ($this->fileSystem->exists($embeddedFile)) {
            return $this->fileSystem->readFromFileInfo(new SplFileInfo($embeddedFile));
        }

        // Error:
        return sprintf('ASCII file %s could not be found.', $file);
    }
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;
    }
429157
protected function handleResource($resource) {
		if ($resource instanceof Resource) {
			return $resource;
		}
		
		// Is not a local resource
		if (preg_match('~^[a-z]+:~', $resource)) {
			$slashPos = strrpos($resource, '/');
			
			$base = substr($resource, 0, $slashPos);
			$name = substr($resource, $slashPos + 1);
			
			$resource = new Resource($name, $base, $base, $this->metadataManager);
		} else {
			$resource = new Resource($resource, $this->basePath, $this->baseUrl, $this->metadataManager);
		}
		
		if ($this->hashAppend) {
			$resource->setHashAppend(true);
		}
		
		return $resource;
	}
1366982
public function getResource($request = NULL)
    {
        if (!$request) {
            $request = new Request();
        }

        $route = $this->route($request);
        $filename = $route->getFilename();
        $className = $route->getClass();

        if ($filename && is_readable($filename)) {
            require_once($filename);
        }

        return new $className($this, $request);
    }
331614
public function makeUrl($resource)
    {
        $host     = trim(str_replace(['http://', 'https://'], null, $this->host), '/');
        $resource = trim($resource, '/');
        //Create URI
        $uri = $host . ':' . $this->port . '/' . $resource;

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

        throw new LoaderException('No matching loader found.');
    }
950822
final protected function findResource($resource, $any = self::LOAD_ONE)
    {
        return $this->locator->locate($resource, $any);
    }
1082405
public function supports($resource)
    {
        return $resource === ''
            || $this->getIssue($resource)
            || $this->jiraService->urlMatches($resource);
    }
1039917
public function get($resource)
    {
        $path = $this->getSourcePath($resource);

        if (!file_exists($path)) {
            throw new \RuntimeException('There is no cached value for '.$resource);
        }

        return include $path;
    }
811500
protected function extractFiles($resource)
    {
        if (\is_array($resource) || $resource instanceof \Traversable) {
            $files = [];
            foreach ($resource as $file) {
                if ($this->canBeExtracted($file)) {
                    $files[] = $this->toSplFileInfo($file);
                }
            }
        } elseif (is_file($resource)) {
            $files = $this->canBeExtracted($resource) ? [$this->toSplFileInfo($resource)] : [];
        } else {
            $files = $this->extractFromDirectory($resource);
        }

        return $files;
    }
939224
public function getRelativeResource($path)
    {
        // Defer to parent module
        $relativeToModule = Path::join($this->relativePath, $path);
        return $this->getModule()->getResource($relativeToModule);
    }