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


PHP ResourceManager::createResourceFromContent方法代码示例

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


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

示例1: handleHashAndData

 /**
  * @param array $source
  * @param PropertyMappingConfigurationInterface $configuration
  * @return Resource|Error
  */
 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->persistenceManager->getObjectByIdentifier($givenResourceIdentity, 'TYPO3\\Flow\\Resource\\Resource');
         if ($resource instanceof \TYPO3\Flow\Resource\Resource) {
             return $resource;
         }
         if ($configuration->getConfigurationValue('TYPO3\\Flow\\Resource\\ResourceTypeConverter', self::CONFIGURATION_IDENTITY_CREATION_ALLOWED) !== TRUE) {
             throw new \TYPO3\Flow\Property\Exception\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) {
         $resourcePointer = $this->persistenceManager->getObjectByIdentifier($hash, 'TYPO3\\Flow\\Resource\\ResourcePointer');
         if ($resourcePointer) {
             $resource = new Resource();
             $resource->setFilename($source['filename']);
             $resource->setResourcePointer($resourcePointer);
         }
     }
     if ($resource === NULL) {
         if (isset($source['data'])) {
             $resource = $this->resourceManager->createResourceFromContent($source['data'], $source['filename']);
         } elseif ($hash !== NULL) {
             $resource = $this->resourceManager->importResource($configuration->getConfigurationValue('TYPO3\\Flow\\Resource\\ResourceTypeConverter', self::CONFIGURATION_RESOURCE_LOAD_PATH) . '/' . $hash);
             if (is_array($source) && isset($source['filename'])) {
                 $resource->setFilename($source['filename']);
             }
         }
     }
     if ($resource instanceof \TYPO3\Flow\Resource\Resource) {
         if ($givenResourceIdentity !== NULL) {
             $this->setIdentity($resource, $givenResourceIdentity);
         }
         return $resource;
     } else {
         return new Error('The resource manager could not create a Resource instance.', 1404312901);
     }
 }
开发者ID:sokunthearith,项目名称:Intern-Project-Week-2,代码行数:51,代码来源:ResourceTypeConverter.php

示例2: importResource

 /**
  * Imports a resource based on exported hash or content
  *
  * @param string $fileName
  * @param string|null $hash
  * @param string|null $content
  * @param string $forcedIdentifier
  * @return \TYPO3\Flow\Resource\Resource
  * @throws NeosException
  */
 protected function importResource($fileName, $hash = null, $content = null, $forcedIdentifier = null)
 {
     if ($hash !== null) {
         $resource = $this->resourceManager->createResourceFromContent(file_get_contents(Files::concatenatePaths(array($this->resourcesPath, $hash))), $fileName);
     } else {
         $resourceData = trim($content);
         if ($resourceData === '') {
             throw new NeosException('Could not import resource because neither "hash" nor "content" tags are present.', 1403009453);
         }
         $decodedResourceData = base64_decode($resourceData);
         if ($decodedResourceData === false) {
             throw new NeosException('Could not import resource because the "content" tag doesn\'t contain valid base64 encoded data.', 1403009477);
         }
         $resource = $this->resourceManager->createResourceFromContent($decodedResourceData, $fileName);
     }
     if ($forcedIdentifier !== null) {
         ObjectAccess::setProperty($resource, 'Persistence_Object_Identifier', $forcedIdentifier, true);
     }
     return $resource;
 }
开发者ID:mgoldbeck,项目名称:neos-development-collection,代码行数:30,代码来源:LegacySiteImportService.php


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