getPublicPackageResourceUri() public method

Returns the public URI for a static resource provided by the specified package and in the given path below the package's resources directory.
public getPublicPackageResourceUri ( string $packageKey, string $relativePathAndFilename ) : string
$packageKey string Package key
$relativePathAndFilename string A relative path below the "Resources" directory of the package
return string
 /**
  * Get the header include code for including Twitter Bootstrap on a page. If needed
  * the jQuery library can be included, too.
  *
  * Example usage:
  * {namespace bootstrap=Neos\Twitter\Bootstrap\ViewHelpers}
  * <bootstrap:include />
  *
  * @param string $version The version to use, for example "2.2", "3.0" or also "2" or "3" meaning "2.x" and "3.x" respectively
  * @param boolean $minified If the minified version of Twitter Bootstrap should be used
  * @param boolean $includeJQuery If enabled, also includes jQuery
  * @param string $jQueryVersion The jQuery version to include
  * @return string
  */
 public function render($version, $minified = TRUE, $includeJQuery = FALSE, $jQueryVersion = '1.10.1')
 {
     $content = sprintf('<link rel="stylesheet" href="%s" />' . PHP_EOL, $this->resourceManager->getPublicPackageResourceUri('Neos\\Twitter.Bootstrap', $version . '/css/bootstrap' . ($minified === TRUE ? '.min' : '') . '.css'));
     if ($includeJQuery === TRUE) {
         $content .= sprintf('<script src="%s"></script>' . PHP_EOL, $this->resourceManager->getPublicPackageResourceUri('Neos\\Twitter.Bootstrap', 'Libraries/jQuery/jquery-' . $jQueryVersion . ($minified === TRUE ? '.min' : '') . '.js'));
     }
     $content .= sprintf('<script src="%s"></script>' . PHP_EOL, $this->resourceManager->getPublicPackageResourceUri('Neos\\Twitter.Bootstrap', $version . '/js/bootstrap' . ($minified === TRUE ? '.min' : '') . '.js'));
     return $content;
 }
 /**
  * Render the URI to the resource. The filename is used from child content.
  *
  * @param string $path The location of the resource, can be either a path relative to the Public resource directory of the package or a resource://... URI
  * @param string $package Target package key. If not set, the current package key will be used
  * @param PersistentResource $resource If specified, this resource object is used instead of the path and package information
  * @param boolean $localize Whether resource localization should be attempted or not
  * @return string The absolute URI to the resource
  * @throws InvalidVariableException
  * @api
  */
 public function render($path = null, $package = null, PersistentResource $resource = null, $localize = true)
 {
     if ($resource !== null) {
         $uri = $this->resourceManager->getPublicPersistentResourceUri($resource);
         if ($uri === false) {
             $uri = '404-Resource-Not-Found';
         }
     } else {
         if ($path === null) {
             throw new InvalidVariableException('The ResourceViewHelper did neither contain a valuable "resource" nor "path" argument.', 1353512742);
         }
         if ($package === null) {
             $package = $this->controllerContext->getRequest()->getControllerPackageKey();
         }
         if (strpos($path, 'resource://') === 0) {
             try {
                 list($package, $path) = $this->resourceManager->getPackageAndPathByPublicPath($path);
             } catch (Exception $exception) {
                 throw new InvalidVariableException(sprintf('The specified path "%s" does not point to a public resource.', $path), 1386458851);
             }
         }
         if ($localize === true) {
             $resourcePath = 'resource://' . $package . '/Public/' . $path;
             $localizedResourcePathData = $this->i18nService->getLocalizedFilename($resourcePath);
             $matches = array();
             if (preg_match('#resource://([^/]+)/Public/(.*)#', current($localizedResourcePathData), $matches) === 1) {
                 $package = $matches[1];
                 $path = $matches[2];
             }
         }
         $uri = $this->resourceManager->getPublicPackageResourceUri($package, $path);
     }
     return $uri;
 }
 /**
  * @param string $resourcePath
  * @return string
  */
 protected function getStaticResourceWebBaseUri($resourcePath)
 {
     $localizedResourcePathData = $this->i18nService->getLocalizedFilename($resourcePath);
     $matches = array();
     try {
         if (preg_match('#resource://([^/]+)/Public/(.*)#', current($localizedResourcePathData), $matches) === 1) {
             $packageKey = $matches[1];
             $path = $matches[2];
             return $this->resourceManager->getPublicPackageResourceUri($packageKey, $path);
         }
     } catch (\Exception $exception) {
         $this->systemLogger->logException($exception);
     }
     return '';
 }
 /**
  * Returns the absolute URL of a resource
  *
  * @return string
  * @throws TypoScriptException
  */
 public function evaluate()
 {
     $resource = $this->getResource();
     if ($resource !== null) {
         $uri = false;
         if ($resource instanceof PersistentResource) {
             $uri = $this->resourceManager->getPublicPersistentResourceUri($resource);
         }
         if ($uri === false) {
             throw new TypoScriptException('The specified resource is invalid', 1386458728);
         }
         return $uri;
     }
     $path = $this->getPath();
     if ($path === null) {
         throw new TypoScriptException('Neither "resource" nor "path" were specified', 1386458763);
     }
     if (strpos($path, 'resource://') === 0) {
         $matches = array();
         if (preg_match('#^resource://([^/]+)/Public/(.*)#', $path, $matches) !== 1) {
             throw new TypoScriptException(sprintf('The specified path "%s" does not point to a public resource.', $path), 1386458851);
         }
         $package = $matches[1];
         $path = $matches[2];
     } else {
         $package = $this->getPackage();
         if ($package === null) {
             $controllerContext = $this->tsRuntime->getControllerContext();
             /** @var $actionRequest ActionRequest */
             $actionRequest = $controllerContext->getRequest();
             $package = $actionRequest->getControllerPackageKey();
         }
     }
     $localize = $this->isLocalize();
     if ($localize === true) {
         $resourcePath = 'resource://' . $package . '/Public/' . $path;
         $localizedResourcePathData = $this->i18nService->getLocalizedFilename($resourcePath);
         $matches = array();
         if (preg_match('#resource://([^/]+)/Public/(.*)#', current($localizedResourcePathData), $matches) === 1) {
             $package = $matches[1];
             $path = $matches[2];
         }
     }
     return $this->resourceManager->getPublicPackageResourceUri($package, $path);
 }