本文整理汇总了PHP中TYPO3\Flow\Resource\ResourceManager::getPublicPersistentResourceUri方法的典型用法代码示例。如果您正苦于以下问题:PHP ResourceManager::getPublicPersistentResourceUri方法的具体用法?PHP ResourceManager::getPublicPersistentResourceUri怎么用?PHP ResourceManager::getPublicPersistentResourceUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\Flow\Resource\ResourceManager
的用法示例。
在下文中一共展示了ResourceManager::getPublicPersistentResourceUri方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* 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 Resource $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, Resource $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;
}
示例2: uploadAction
/**
* Upload a new image and return an image variant, a thumbnail and additional information like it would be
* returned for the Neos backend.
*
* @param Image $image
* @return string
*/
public function uploadAction(Image $image)
{
$this->assetRepository->add($image);
$imageVariant = new ImageVariant($image);
$this->assetRepository->add($imageVariant);
$thumbnail = $image->getThumbnail(100, 100);
$this->response->setHeader('Content-Type', 'application/json');
return json_encode(array('__identity' => $this->persistenceManager->getIdentifierByObject($image), '__resourceUri' => $this->resourceManager->getPublicPersistentResourceUri($image->getResource()), 'width' => $image->getWidth(), 'height' => $image->getHeight(), 'thumbnail' => array('__resourceUri' => $this->resourceManager->getPublicPersistentResourceUri($thumbnail->getResource()), 'width' => $thumbnail->getWidth(), 'height' => $thumbnail->getHeight()), 'variants' => array(array('__identity' => $this->persistenceManager->getIdentifierByObject($imageVariant), '__resourceUri' => $this->resourceManager->getPublicPersistentResourceUri($imageVariant->getResource()), 'width' => $imageVariant->getWidth(), 'height' => $imageVariant->getHeight()))));
}
示例3: getThumbnailUriAndSizeForAsset
/**
* Calculates the dimensions of the thumbnail to be generated and returns the thumbnail URI.
* In case of Images this is a thumbnail of the image, in case of other assets an icon representation.
*
* @param AssetInterface $asset
* @param ThumbnailConfiguration $configuration
* @return array with keys "width", "height" and "src"
*/
public function getThumbnailUriAndSizeForAsset(AssetInterface $asset, ThumbnailConfiguration $configuration)
{
if ($asset instanceof ImageInterface) {
$thumbnailImage = $this->thumbnailService->getThumbnail($asset, $configuration);
$thumbnailData = array('width' => $thumbnailImage->getWidth(), 'height' => $thumbnailImage->getHeight(), 'src' => $this->resourceManager->getPublicPersistentResourceUri($thumbnailImage->getResource()));
} else {
$thumbnailData = $this->getAssetThumbnailImage($asset, $configuration->getWidth() ?: $configuration->getMaximumWidth(), $configuration->getHeight() ?: $configuration->getMaximumHeight());
}
return $thumbnailData;
}
示例4: getThumbnailUriAndSizeForAsset
/**
* Calculates the dimensions of the thumbnail to be generated and returns the thumbnail URI.
* In case of Images this is a thumbnail of the image, in case of other assets an icon representation.
*
* @param AssetInterface $asset
* @param integer $maximumWidth
* @param integer $maximumHeight
* @param boolean $allowCropping
* @param boolean $allowUpScaling
* @return array with keys "width", "height" and "src"
*/
public function getThumbnailUriAndSizeForAsset(AssetInterface $asset, $maximumWidth, $maximumHeight, $allowCropping = FALSE, $allowUpScaling = NULL)
{
if ($asset instanceof ImageInterface) {
$thumbnailImage = $this->getImageThumbnailImage($asset, $maximumWidth, $maximumHeight, $allowCropping, $allowUpScaling);
$thumbnailData = array('width' => $thumbnailImage->getWidth(), 'height' => $thumbnailImage->getHeight(), 'src' => $this->resourceManager->getPublicPersistentResourceUri($thumbnailImage->getResource()));
} else {
$thumbnailData = $this->getAssetThumbnailImage($asset, $maximumWidth, $maximumHeight);
}
return $thumbnailData;
}
示例5: resolveAssetUri
/**
* Resolves a given asset:// URI to a "normal" HTTP(S) URI for the addressed asset's resource.
*
* @param string|Uri $uri
* @return string
*/
public function resolveAssetUri($uri)
{
$targetObject = $this->convertUriToObject($uri);
if ($targetObject === null) {
$this->systemLogger->log(sprintf('Could not resolve "%s" to an existing asset; The asset was probably deleted.', $uri));
return null;
}
return $this->resourceManager->getPublicPersistentResourceUri($targetObject->getResource());
}
示例6: getImagePreviewData
/**
* @param Image $image
* @return array
*/
protected function getImagePreviewData(Image $image)
{
$imageProperties = ['originalImageResourceUri' => $this->resourceManager->getPublicPersistentResourceUri($image->getResource()), 'originalDimensions' => ['width' => $image->getWidth(), 'height' => $image->getHeight(), 'aspectRatio' => $image->getAspectRatio()], 'mediaType' => $image->getResource()->getMediaType()];
$thumbnail = $this->thumbnailService->getThumbnail($image, $this->thumbnailService->getThumbnailConfigurationForPreset('TYPO3.Neos:Preview'));
if ($thumbnail !== null) {
$imageProperties['previewImageResourceUri'] = $this->thumbnailService->getUriForThumbnail($thumbnail);
$imageProperties['previewDimensions'] = ['width' => $thumbnail->getWidth(), 'height' => $thumbnail->getHeight()];
}
return $imageProperties;
}
示例7: getUriForThumbnail
/**
* @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);
}
示例8: getThumbnailUriAndSizeForAsset
/**
* Calculates the dimensions of the thumbnail to be generated and returns the thumbnail URI.
* In case of Images this is a thumbnail of the image, in case of other assets an icon representation.
*
* @param AssetInterface $asset
* @param ThumbnailConfiguration $configuration
* @param ActionRequest $request Request argument must be provided for asynchronous thumbnails
* @return array|null Array with keys "width", "height" and "src" if the thumbnail generation work or null
* @throws AssetServiceException
*/
public function getThumbnailUriAndSizeForAsset(AssetInterface $asset, ThumbnailConfiguration $configuration, ActionRequest $request = null)
{
$thumbnailImage = $this->thumbnailService->getThumbnail($asset, $configuration);
if (!$thumbnailImage instanceof ImageInterface) {
return null;
}
$resource = $thumbnailImage->getResource();
if ($thumbnailImage instanceof Thumbnail) {
$staticResource = $thumbnailImage->getStaticResource();
if ($configuration->isAsync() === true && $resource === null && $staticResource === null) {
if ($request === null) {
throw new AssetServiceException('Request argument must be provided for async thumbnails.', 1447660835);
}
$this->uriBuilder->setRequest($request->getMainRequest());
$uri = $this->uriBuilder->reset()->setCreateAbsoluteUri(true)->uriFor('thumbnail', array('thumbnail' => $thumbnailImage), 'Thumbnail', 'TYPO3.Media');
} else {
$uri = $this->thumbnailService->getUriForThumbnail($thumbnailImage);
}
} else {
$uri = $this->resourceManager->getPublicPersistentResourceUri($resource);
}
return array('width' => $thumbnailImage->getWidth(), 'height' => $thumbnailImage->getHeight(), 'src' => $uri);
}
示例9: render
/**
* 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 Resource $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, Resource $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) {
$matches = array();
if (preg_match('#^resource://([^/]+)/Public/(.*)#', $path, $matches) === 1) {
$package = $matches[1];
$path = $matches[2];
} else {
throw new InvalidVariableException(sprintf('The path "%s" which was given to the ResourceViewHelper must point to a public resource.', $path), 1353512639);
}
}
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;
}
示例10: getUriForThumbnail
/**
* @param Thumbnail $thumbnail
* @return string
* @throws ThumbnailServiceException
*/
public function getUriForThumbnail(Thumbnail $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);
}
try {
list($package, $path) = $this->resourceManager->getPackageAndPathByPublicPath($staticResource);
return $this->resourceManager->getPublicPackageResourceUri($package, $path);
} catch (Exception $exception) {
return $staticResource;
}
}
示例11: evaluate
/**
* 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 Resource) {
$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);
}
示例12: replaceAssetResource
/**
* Replace resource on an asset. Takes variants and redirect handling into account.
*
* @param AssetInterface $asset
* @param FlowResource $resource
* @param array $options
* @return void
*/
public function replaceAssetResource(AssetInterface $asset, FlowResource $resource, array $options = [])
{
$originalAssetResource = $asset->getResource();
$asset->setResource($resource);
if (isset($options['keepOriginalFilename']) && (bool) $options['keepOriginalFilename'] === true) {
$asset->getResource()->setFilename($originalAssetResource->getFilename());
}
$uriMapping = [];
$redirectHandlerEnabled = isset($options['generateRedirects']) && (bool) $options['generateRedirects'] === true && $this->packageManager->isPackageAvailable('Neos.RedirectHandler');
if ($redirectHandlerEnabled) {
$uriMapping[$this->resourceManager->getPublicPersistentResourceUri($originalAssetResource)] = $this->resourceManager->getPublicPersistentResourceUri($asset->getResource());
}
if (method_exists($asset, 'getVariants')) {
$variants = $asset->getVariants();
foreach ($variants as $variant) {
$originalVariantResource = $variant->getResource();
$variant->refresh();
foreach ($variant->getAdjustments() as $adjustment) {
if (method_exists($adjustment, 'refit')) {
$adjustment->refit($asset);
}
}
if ($redirectHandlerEnabled) {
$uriMapping[$this->resourceManager->getPublicPersistentResourceUri($originalVariantResource)] = $this->resourceManager->getPublicPersistentResourceUri($variant->getResource());
}
$this->getRepository($variant)->update($variant);
}
}
if ($redirectHandlerEnabled) {
/** @var \Neos\RedirectHandler\Storage\RedirectStorageInterface $redirectStorage */
$redirectStorage = $this->objectManager->get(\Neos\RedirectHandler\Storage\RedirectStorageInterface::class);
foreach ($uriMapping as $originalUri => $newUri) {
$existingRedirect = $redirectStorage->getOneBySourceUriPathAndHost($originalUri);
if ($existingRedirect === null) {
$redirectStorage->addRedirect($originalUri, $newUri, 301);
}
}
}
$this->getRepository($asset)->update($asset);
$this->emitAssetResourceReplaced($asset);
}
示例13: getPersistentResourceWebUri
/**
* Returns the URI pointing to the published persistent resource
*
* @param \TYPO3\Flow\Resource\Resource $resource The resource to publish
* @return mixed Either the web URI of the published resource or FALSE if the resource source file doesn't exist or the resource could not be published for other reasons
* @deprecated since Flow 3.0. Use ResourceManager->getPublicPersistentResourceUri($resource) instead
*/
public function getPersistentResourceWebUri(Resource $resource)
{
$this->systemLogger->log('The deprecated method ResourcePublisher->getPersistentResourceWebUri() has been called' . $this->getCallee() . '. Please use ResourceManager->getPublicPersistentResourceUri() instead!', LOG_WARNING);
return $this->resourceManager->getPublicPersistentResourceUri($resource);
}
示例14: getImagePreviewData
/**
* @param Image $image
* @return array
*/
protected function getImagePreviewData(Image $image)
{
$thumbnail = $image->getThumbnail(600, 600);
$imageProperties = array('originalImageResourceUri' => $this->resourceManager->getPublicPersistentResourceUri($image->getResource()), 'previewImageResourceUri' => $this->resourceManager->getPublicPersistentResourceUri($thumbnail->getResource()), 'originalDimensions' => array('width' => $image->getWidth(), 'height' => $image->getHeight(), 'aspectRatio' => $image->getAspectRatio()), 'previewDimensions' => array('width' => $thumbnail->getWidth(), 'height' => $thumbnail->getHeight()), 'mediaType' => $image->getResource()->getMediaType());
return $imageProperties;
}
示例15: render
/**
* @param array $items array of Resources,Assets or strings (uri)
* @param string $id of the carousel instance
* @param string $class class attribute of carousel element
* @param bool $autoinclude include scripts and styles if not already done
* @param int $numItems number of items to display at once
* @param bool $itemsScaleUp scale up carousel items
* @param bool $singleItem always display a single item
* @param bool $showNavigation show carousel navigation
* @param bool $pagination enable pagination
* @param int $paginationSpeed speed of the pagination
* @param bool $paginationNumbers show pagination numbers
* @param bool $rewindNavigation rewind navigation on end
* @param bool $autoplay enable autoplay
* @param int $autoplaySpeed speed of autoplay
* @param bool $pauseOnHover pause autoplay on hover
* @param bool $loop loop animation instead of rewind
* @param bool $isResponsive enable responsive design
* @param array<string,int> $responsiveConfig responsive configuration array("{minScreenSize}" => [numElements],...))
* @param int $itemMaxWidth image thumbnail max width
* @param int $itemMaxHeight image thumbnail max height
* @param bool $itemAllowCropping allow cropping thumbnails
* @param bool $itemAllowUpscaling allow upscaling thumbnails
*
* @return string
*/
public function render($items, $id = null, $class = null, $autoinclude = true, $numItems = 1, $itemsScaleUp = true, $singleItem = true, $showNavigation = true, $pagination = true, $paginationSpeed = 800, $paginationNumbers = true, $rewindNavigation = true, $autoplay = true, $autoplaySpeed = 200, $pauseOnHover = true, $loop = true, $isResponsive = false, $responsiveConfig = array("0" => 1, "479" => 2, "768" => 3, "1199" => 5), $itemMaxWidth = null, $itemMaxHeight = null, $itemAllowCropping = false, $itemAllowUpscaling = false)
{
if ($id == null) {
$id = 'oc' . md5(microtime());
}
if ($class == null) {
$class = 'owl-carousel';
} else {
$class .= ' owl-carousel';
}
//build config array
$config = array();
$config['items'] = $numItems;
$config['itemsScaleUp'] = $itemsScaleUp;
$config['singleItem'] = $singleItem;
$config['nav'] = $showNavigation;
$config['pagination'] = $pagination;
$config['paginationSpeed'] = $paginationSpeed;
$config['paginationNumbers'] = $paginationNumbers;
$config['rewindNav'] = $rewindNavigation;
$config['autoplay'] = $autoplay;
$config['autoplaySpeed'] = $autoplaySpeed;
$config['autoplayHoverPause'] = $pauseOnHover;
$config['loop'] = $loop;
$config['responsiveClass'] = $isResponsive;
//include dependencies if necessary
$includeContent = '';
if ($autoinclude) {
$viewHelper = $this->objectManager->get('Axovis\\Flow\\Owlcarousel\\ViewHelpers\\IncludeViewHelper');
$includeContent = $viewHelper->render(true, 'remaining');
}
//build items content
$itemsContent = '';
foreach ($items as $item) {
$title = '';
$caption = '';
if ($item instanceof Resource) {
$uri = $this->resourceManager->getPublicPersistentResourceUri($item);
} else {
if ($item instanceof Asset) {
$thumbnailConfiguration = new ThumbnailConfiguration(null, $itemMaxWidth, null, $itemMaxHeight, $itemAllowCropping, $itemAllowUpscaling, false);
$uri = $this->assetService->getThumbnailUriAndSizeForAsset($item, $thumbnailConfiguration)['src'];
//$uri = $this->resourceManager->getPublicPersistentResourceUri($item->getResource());
$title = $item->getTitle();
$caption = $item->getCaption();
} else {
if (is_string($item)) {
$uri = $item;
} else {
$title = 'Dummy Image';
$uri = $this->resourceManager->getPublicPackageResourceUri('Axovis.Flow.Owlcarousel', 'Images/dummy-image.png');
}
}
}
$itemsContent .= '
<div class="item">
<div>
<img src="' . $uri . '" title="' . $title . '" alt="' . $title . '" />
<div class="carousel-caption">
' . $caption . '
</div>
</div>
</div>
';
}
//build responsive config content
$responsiveConfigContent = '';
if ($isResponsive) {
$responsiveConfigContent = 'config.responsive = {};';
foreach ($responsiveConfig as $screen => $numItems) {
$responsiveConfigContent .= '
config.responsive["' . $screen . '"] = {};
config.responsive["' . $screen . '"].items = ' . $numItems . ';
';
//.........这里部分代码省略.........