本文整理汇总了PHP中TYPO3\Flow\Resource\ResourceManager::getPackageAndPathByPublicPath方法的典型用法代码示例。如果您正苦于以下问题:PHP ResourceManager::getPackageAndPathByPublicPath方法的具体用法?PHP ResourceManager::getPackageAndPathByPublicPath怎么用?PHP ResourceManager::getPackageAndPathByPublicPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\Flow\Resource\ResourceManager
的用法示例。
在下文中一共展示了ResourceManager::getPackageAndPathByPublicPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
}