本文整理汇总了PHP中TYPO3\Flow\Resource\ResourceManager::getPersistentResourcesStorageBaseUri方法的典型用法代码示例。如果您正苦于以下问题:PHP ResourceManager::getPersistentResourcesStorageBaseUri方法的具体用法?PHP ResourceManager::getPersistentResourcesStorageBaseUri怎么用?PHP ResourceManager::getPersistentResourcesStorageBaseUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\Flow\Resource\ResourceManager
的用法示例。
在下文中一共展示了ResourceManager::getPersistentResourcesStorageBaseUri方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: evaluateResourcePath
/**
* Evaluates the absolute path and filename of the resource file specified
* by the given path.
*
* @param string $requestedPath
* @param boolean $checkForExistence Whether a (non-hash) path should be checked for existence before being returned
* @return mixed The full path and filename or FALSE if the file doesn't exist
* @throws \TYPO3\Flow\Resource\Exception
* @throws \InvalidArgumentException
*/
protected function evaluateResourcePath($requestedPath, $checkForExistence = TRUE)
{
if (substr($requestedPath, 0, strlen(self::SCHEME)) !== self::SCHEME) {
throw new \InvalidArgumentException('The ' . __CLASS__ . ' only supports the \'' . self::SCHEME . '\' scheme.', 1256052544);
}
$uriParts = parse_url($requestedPath);
if (!is_array($uriParts) || !isset($uriParts['host'])) {
return FALSE;
}
if (preg_match('/^[0-9a-f]{40}$/i', $uriParts['host']) === 1) {
$resourcePath = $this->resourceManager->getPersistentResourcesStorageBaseUri() . $uriParts['host'];
if ($checkForExistence === FALSE || file_exists($resourcePath)) {
return $resourcePath;
} else {
return FALSE;
}
}
if (!$this->packageManager->isPackageAvailable($uriParts['host'])) {
throw new \TYPO3\Flow\Resource\Exception(sprintf('Invalid resource URI "%s": Package "%s" is not available.', $requestedPath, $uriParts['host']), 1309269952);
}
$package = $this->packageManager->getPackage($uriParts['host']);
$resourcePath = \TYPO3\Flow\Utility\Files::concatenatePaths(array($package->getResourcesPath(), $uriParts['path']));
if ($checkForExistence === FALSE || file_exists($resourcePath)) {
return $resourcePath;
}
return FALSE;
}
示例2: downloadFile
/**
* Downloads the file
*
* @param array $file The file
* @return void
*/
public function downloadFile(array $file)
{
$fileResource = $this->propertyMapper->convert($file['__identity'], '\\TYPO3\\Flow\\Resource\\Resource');
$filePath = $this->resourceManager->getPersistentResourcesStorageBaseUri() . $fileResource->getResourcePointer()->getHash();
$fileMimeType = mime_content_type($filePath);
header('Content-Description: File Transfer');
header('Content-Type: ' . $fileMimeType);
header('Content-Disposition: attachment; filename=' . basename($fileResource->getFilename()));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($filePath));
ob_clean();
flush();
readfile($filePath);
}