当前位置: 首页>>代码示例>>PHP>>正文


PHP ResourceManager::getPersistentResourcesStorageBaseUri方法代码示例

本文整理汇总了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;
 }
开发者ID:sokunthearith,项目名称:Intern-Project-Week-2,代码行数:37,代码来源:ResourceStreamWrapper.php

示例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);
 }
开发者ID:abedsujan,项目名称:Lelesys.Plugin.News,代码行数:23,代码来源:NewsService.php


注:本文中的TYPO3\Flow\Resource\ResourceManager::getPersistentResourcesStorageBaseUri方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。