本文整理汇总了PHP中TYPO3\Flow\Resource\ResourceManager::getStreamByResource方法的典型用法代码示例。如果您正苦于以下问题:PHP ResourceManager::getStreamByResource方法的具体用法?PHP ResourceManager::getStreamByResource怎么用?PHP ResourceManager::getStreamByResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\Flow\Resource\ResourceManager
的用法示例。
在下文中一共展示了ResourceManager::getStreamByResource方法的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 \InvalidArgumentException|Exception
*/
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 = Functions::parse_url($requestedPath);
if (!is_array($uriParts) || !isset($uriParts['host'])) {
return false;
}
if (preg_match('/^[0-9a-f]{40}$/i', $uriParts['host']) === 1) {
$resource = $this->resourceManager->getResourceBySha1($uriParts['host']);
return $this->resourceManager->getStreamByResource($resource);
}
if (!$this->packageManager->isPackageAvailable($uriParts['host'])) {
throw new Exception(sprintf('Invalid resource URI "%s": Package "%s" is not available.', $requestedPath, $uriParts['host']), 1309269952);
}
$package = $this->packageManager->getPackage($uriParts['host']);
$resourceUri = Files::concatenatePaths(array($package->getResourcesPath(), $uriParts['path']));
if ($checkForExistence === false || file_exists($resourceUri)) {
return $resourceUri;
}
return false;
}
示例2: getStream
/**
* Returns a stream for use with read-only file operations such as reading or copying.
*
* Note: The caller is responsible to close the returned resource by calling fclose($stream)
*
* @return resource | boolean A stream which points to the data of this resource for read-access or FALSE if the stream could not be obtained
* @api
*/
public function getStream()
{
return $this->resourceManager->getStreamByResource($this);
}