getPublicPackageResourceUriByPath() public method

Returns the public URI for a static resource provided by the public package
public getPublicPackageResourceUriByPath ( string $path ) : string
$path string The ressource path, like resource://Your.Package/Public/Image/Dummy.png
return string
 /**
  * Renders an <img> HTML tag for a filetype icon for a given Neos.Media's asset instance
  *
  * @param AssetInterface $file
  * @param integer|null $width
  * @param integer|null $height
  * @return string
  */
 public function render(AssetInterface $file, $width = null, $height = null)
 {
     $icon = FileTypeIconService::getIcon($file, $width, $height);
     $this->tag->addAttribute('src', $this->resourceManager->getPublicPackageResourceUriByPath($icon['src']));
     $this->tag->addAttribute('alt', $icon['alt']);
     if ($width !== null) {
         $this->tag->addAttribute('width', $width);
     }
     if ($height !== null) {
         $this->tag->addAttribute('height', $height);
     }
     return $this->tag->render();
 }
示例#2
0
 /**
  * @param string $presetName name of the preset to use
  * @return string the rendered form head
  */
 public function render($presetName = 'default')
 {
     $content = '';
     $presetConfiguration = $this->formBuilderFactory->getPresetConfiguration($presetName);
     $stylesheets = isset($presetConfiguration['stylesheets']) ? $presetConfiguration['stylesheets'] : [];
     foreach ($stylesheets as $stylesheet) {
         $content .= sprintf('<link href="%s" rel="stylesheet">', $this->resourceManager->getPublicPackageResourceUriByPath($stylesheet['source']));
     }
     $javaScripts = isset($presetConfiguration['javaScripts']) ? $presetConfiguration['javaScripts'] : [];
     foreach ($javaScripts as $javaScript) {
         $content .= sprintf('<script src="%s"></script>', $this->resourceManager->getPublicPackageResourceUriByPath($javaScript['source']));
     }
     return $content;
 }
 /**
  * @param ImageInterface $thumbnail
  * @return string
  * @throws ThumbnailServiceException
  */
 public function getUriForThumbnail(ImageInterface $thumbnail)
 {
     $resource = $thumbnail->getResource();
     if ($resource) {
         return $this->resourceManager->getPublicPersistentResourceUri($resource);
     }
     $staticResource = $thumbnail->getStaticResource();
     if ($staticResource === null) {
         throw new ThumbnailServiceException(sprintf('Could not generate URI for static thumbnail "%s".', $this->persistenceManager->getIdentifierByObject($thumbnail)), 1450178437);
     }
     return $this->resourceManager->getPublicPackageResourceUriByPath($staticResource);
 }
 /**
  * Resolve help message thumbnail url
  *
  * @param string $nodeTypeName
  * @param string $configurationThumbnail
  * @return string $thumbnailUrl
  */
 protected function resolveHelpMessageThumbnail($nodeTypeName, $configurationThumbnail)
 {
     if ($nodeTypeName !== null) {
         $thumbnailUrl = '';
         if (isset($configurationThumbnail)) {
             $thumbnailUrl = $configurationThumbnail;
             if (strpos($thumbnailUrl, 'resource://') === 0) {
                 $thumbnailUrl = $this->resourceManager->getPublicPackageResourceUriByPath($thumbnailUrl);
             }
         } else {
             # look in well know location
             $splitPrefix = $this->splitIdentifier($nodeTypeName);
             $relativePathAndFilename = 'NodeTypes/Thumbnails/' . $splitPrefix['id'] . '.png';
             $resourcePath = 'resource://' . $splitPrefix['packageKey'] . '/Public/' . $relativePathAndFilename;
             if (file_exists($resourcePath)) {
                 $thumbnailUrl = $this->resourceManager->getPublicPackageResourceUriByPath($resourcePath);
             }
         }
         return $thumbnailUrl;
     }
 }