/**
  * @param array $databaseRow
  * @return ProcessedFile
  */
 protected function createDomainObject(array $databaseRow)
 {
     $originalFile = $this->resourceFactory->getFileObject((int) $databaseRow['original']);
     $originalFile->setStorage($this->resourceFactory->getStorageObject($originalFile->getProperty('storage')));
     $taskType = $databaseRow['task_type'];
     $configuration = unserialize($databaseRow['configuration']);
     return GeneralUtility::makeInstance($this->objectType, $originalFile, $taskType, $configuration, $databaseRow);
 }
Esempio n. 2
0
 /**
  * Actually convert from $source to $targetType, taking into account the fully
  * built $convertedChildProperties and $configuration.
  *
  * @param string|int $source
  * @param string $targetType
  * @param array $convertedChildProperties
  * @param PropertyMappingConfigurationInterface $configuration
  * @return AbstractFileFolder
  * @internal
  */
 public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)
 {
     if (!isset($source['error']) || $source['error'] === \UPLOAD_ERR_NO_FILE) {
         if (isset($source['submittedFile']['resourcePointer'])) {
             try {
                 $resourcePointer = $this->hashService->validateAndStripHmac($source['submittedFile']['resourcePointer']);
                 if (strpos($resourcePointer, 'file:') === 0) {
                     $fileUid = substr($resourcePointer, 5);
                     return $this->createFileReferenceFromFalFileObject($this->resourceFactory->getFileObject($fileUid));
                 } else {
                     return $this->createFileReferenceFromFalFileReferenceObject($this->resourceFactory->getFileReferenceObject($resourcePointer), $resourcePointer);
                 }
             } catch (\InvalidArgumentException $e) {
                 // Nothing to do. No file is uploaded and resource pointer is invalid. Discard!
             }
         }
         return null;
     }
     if ($source['error'] !== \UPLOAD_ERR_OK) {
         return $this->objectManager->get(Error::class, $this->getUploadErrorMessage($source['error']), 1471715915);
     }
     if (isset($this->convertedResources[$source['tmp_name']])) {
         return $this->convertedResources[$source['tmp_name']];
     }
     try {
         $resource = $this->importUploadedResource($source, $configuration);
     } catch (\Exception $e) {
         return $this->objectManager->get(Error::class, $e->getMessage(), $e->getCode());
     }
     $this->convertedResources[$source['tmp_name']] = $resource;
     return $resource;
 }
Esempio n. 3
0
	/**
	 * Get File or FileReference object by src
	 *
	 * @param string $src
	 * @param bool $treatIdAsReference
	 * @return FileInterface|FileReference|\TYPO3\CMS\Core\Resource\Folder
	 */
	protected function getImageFromSourceString($src, $treatIdAsReference) {
		if ($this->environmentService->isEnvironmentInBackendMode() && substr($src, 0, 3) === '../') {
			$src = substr($src, 3);
		}
		if (MathUtility::canBeInterpretedAsInteger($src)) {
			if ($treatIdAsReference) {
				$image = $this->resourceFactory->getFileReferenceObject($src);
			} else {
				$image = $this->resourceFactory->getFileObject($src);
			}
		} else {
			// We have a combined identifier or legacy (storage 0) path
			$image = $this->resourceFactory->retrieveFileOrFolderObject($src);
		}
		return $image;
	}
 /**
  * Actually convert from $source to $targetType, taking into account the fully
  * built $convertedChildProperties and $configuration.
  *
  * @param string|integer $source
  * @param string $targetType
  * @param array $convertedChildProperties
  * @param \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration
  * @throws \TYPO3\CMS\Extbase\Property\Exception
  * @return \TYPO3\CMS\Extbase\Domain\Model\AbstractFileFolder
  * @api
  */
 public function convertFrom($source, $targetType, array $convertedChildProperties = array(), PropertyMappingConfigurationInterface $configuration = NULL)
 {
     if (!isset($source['error']) || $source['error'] === \UPLOAD_ERR_NO_FILE) {
         if (isset($source['submittedFile']['resourcePointer'])) {
             try {
                 $resourcePointer = $this->hashService->validateAndStripHmac($source['submittedFile']['resourcePointer']);
                 if (strpos($resourcePointer, 'file:') === 0) {
                     $fileUid = substr($resourcePointer, 5);
                     return $this->createFileReferenceFromFalFileObject($this->resourceFactory->getFileObject($fileUid));
                 } else {
                     return $this->createFileReferenceFromFalFileReferenceObject($this->resourceFactory->getFileReferenceObject($resourcePointer), $resourcePointer);
                 }
             } catch (\InvalidArgumentException $e) {
                 // Nothing to do. No file is uploaded and resource pointer is invalid. Discard!
             }
         }
         return NULL;
     }
     if ($source['error'] !== \UPLOAD_ERR_OK) {
         switch ($source['error']) {
             case \UPLOAD_ERR_INI_SIZE:
             case \UPLOAD_ERR_FORM_SIZE:
             case \UPLOAD_ERR_PARTIAL:
                 return new Error(Files::getUploadErrorMessage($source['error']), 1264440823);
             default:
                 return new Error('An error occurred while uploading. Please try again or contact the administrator if the problem remains', 1340193849);
         }
     }
     if (isset($this->convertedResources[$source['tmp_name']])) {
         return $this->convertedResources[$source['tmp_name']];
     }
     try {
         $resource = $this->importUploadedResource($source, $configuration);
     } catch (\Exception $e) {
         return new Error($e->getMessage(), $e->getCode());
     }
     $this->convertedResources[$source['tmp_name']] = $resource;
     return $resource;
 }
 /**
  * @param integer $uid
  * @return array
  */
 public function getInfoByUid($uid)
 {
     $file = $this->resourceFactory->getFileObject($uid);
     return ResourceUtility::getFileArray($file);
 }