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


PHP ResourceManager::importResourceFromContent方法代码示例

本文整理汇总了PHP中TYPO3\Flow\Resource\ResourceManager::importResourceFromContent方法的典型用法代码示例。如果您正苦于以下问题:PHP ResourceManager::importResourceFromContent方法的具体用法?PHP ResourceManager::importResourceFromContent怎么用?PHP ResourceManager::importResourceFromContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TYPO3\Flow\Resource\ResourceManager的用法示例。


在下文中一共展示了ResourceManager::importResourceFromContent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: buildAssetObject

 /**
  * @return Asset
  * @throws \TYPO3\Flow\Resource\Exception
  */
 protected function buildAssetObject()
 {
     $resource = $this->resourceManager->importResourceFromContent('Test', 'test.txt');
     $asset = new Asset($resource);
     $this->assetRepository->add($asset);
     return $asset;
 }
开发者ID:robertlemke,项目名称:neos-development-collection,代码行数:11,代码来源:AssetTest.php

示例2: handleHashAndData

 /**
  * @param array $source
  * @param PropertyMappingConfigurationInterface $configuration
  * @return Resource|Error
  * @throws Exception
  * @throws InvalidPropertyMappingConfigurationException
  */
 protected function handleHashAndData(array $source, PropertyMappingConfigurationInterface $configuration = null)
 {
     $hash = null;
     $resource = false;
     $givenResourceIdentity = null;
     if (isset($source['__identity'])) {
         $givenResourceIdentity = $source['__identity'];
         unset($source['__identity']);
         $resource = $this->resourceRepository->findByIdentifier($givenResourceIdentity);
         if ($resource instanceof Resource) {
             return $resource;
         }
         if ($configuration->getConfigurationValue(\TYPO3\Flow\Resource\ResourceTypeConverter::class, self::CONFIGURATION_IDENTITY_CREATION_ALLOWED) !== true) {
             throw new InvalidPropertyMappingConfigurationException('Creation of resource objects with identity not allowed. To enable this, you need to set the PropertyMappingConfiguration Value "CONFIGURATION_IDENTITY_CREATION_ALLOWED" to TRUE');
         }
     }
     if (isset($source['hash']) && preg_match('/[0-9a-f]{40}/', $source['hash'])) {
         $hash = $source['hash'];
     }
     if ($hash !== null && count($source) === 1) {
         $resource = $this->resourceManager->getResourceBySha1($hash);
     }
     if ($resource === null) {
         $collectionName = $this->getCollectionName($source, $configuration);
         if (isset($source['data'])) {
             $resource = $this->resourceManager->importResourceFromContent($source['data'], $source['filename'], $collectionName, $givenResourceIdentity);
         } elseif ($hash !== null) {
             $resource = $this->resourceManager->importResource($configuration->getConfigurationValue(\TYPO3\Flow\Resource\ResourceTypeConverter::class, self::CONFIGURATION_RESOURCE_LOAD_PATH) . '/' . $hash, $collectionName, $givenResourceIdentity);
             if (is_array($source) && isset($source['filename'])) {
                 $resource->setFilename($source['filename']);
             }
         }
     }
     if ($resource instanceof Resource) {
         return $resource;
     } else {
         return new Error('The resource manager could not create a Resource instance.', 1404312901);
     }
 }
开发者ID:robertlemke,项目名称:flow-development-collection,代码行数:46,代码来源:ResourceTypeConverter.php

示例3: fileGetContentsReturnFixtureContentForResourceUri

 /**
  * @test
  */
 public function fileGetContentsReturnFixtureContentForResourceUri()
 {
     /** @var \TYPO3\Flow\Resource\Resource $resource */
     $resource = $this->resourceManager->importResourceFromContent('fixture', 'fixture.txt');
     $this->assertEquals('fixture', file_get_contents('resource://' . $resource->getSha1()));
 }
开发者ID:fcool,项目名称:flow-development-collection,代码行数:9,代码来源:ResourceTest.php


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