/**
  * Actually convert from $source to $targetType, taking into account the fully
  * built $convertedChildProperties and $configuration.
  *
  * The return value can be one of three types:
  * - an arbitrary object, or a simple type (which has been created while mapping).
  *   This is the normal case.
  * - NULL, indicating that this object should *not* be mapped (i.e. a "File Upload" Converter could return NULL if no file has been uploaded, and a silent failure should occur.
  * - An instance of \TYPO3\CMS\Extbase\Error\Error -- This will be a user-visible error message later on.
  * Furthermore, it should throw an Exception if an unexpected failure (like a security error) occurred or a configuration issue happened.
  *
  * @param mixed $source
  * @param string $targetType
  * @param array $convertedChildProperties
  * @param \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration
  *
  * @return mixed|\TYPO3\CMS\Extbase\Error\Error the target type, or an error object if a user-error occurred
  *
  * @throws \TYPO3\CMS\Extbase\Property\Exception\TypeConverterException thrown in case a developer error occurred
  */
 public function convertFrom($source, $targetType, array $convertedChildProperties = array(), \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration = null)
 {
     /** @var \TYPO3\CMS\Extbase\Domain\Model\FileReference $alreadyPersistedImage */
     $alreadyPersistedImage = $configuration->getConfigurationValue('JWeiland\\Clubdirectory\\Property\\TypeConverter\\UploadOneFileConverter', 'IMAGE');
     // if no file was uploaded use the already persisted one
     if (!isset($source['error']) || !isset($source['name']) || !isset($source['size']) || !isset($source['tmp_name']) || !isset($source['type']) || $source['error'] === 4) {
         return $alreadyPersistedImage;
     }
     // check if uploaded file returns an error
     if ($source['error'] !== 0) {
         return new \TYPO3\CMS\Extbase\Error\Error(LocalizationUtility::translate('error.upload', 'clubdirectory') . $source['error'], 1396957314);
     }
     // now we have a valid uploaded file. Check if user has rights to upload this file
     if (!isset($source['rights']) || empty($source['rights'])) {
         return new \TYPO3\CMS\Extbase\Error\Error(LocalizationUtility::translate('error.uploadRights', 'clubdirectory'), 1397464390);
     }
     // check if file extension is allowed
     $fileParts = GeneralUtility::split_fileref($source['name']);
     if (!GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileParts['fileext'])) {
         return new \TYPO3\CMS\Extbase\Error\Error(LocalizationUtility::translate('error.fileExtension', 'clubdirectory', array($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'])), 1402981282);
     }
     // before uploading the new file we should remove the old one
     if ($alreadyPersistedImage instanceof \TYPO3\CMS\Extbase\Domain\Model\FileReference) {
         $alreadyPersistedImage->getOriginalResource()->delete();
     }
     return $this->getExtbaseFileReference($source);
 }
 /**
  * @param \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration
  * @return string
  * @throws \TYPO3\CMS\Extbase\Property\Exception\InvalidPropertyMappingConfigurationException
  */
 protected function getConfiguredStringDelimiter(\TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration = NULL)
 {
     if ($configuration === NULL) {
         return self::DEFAULT_STRING_DELIMITER;
     }
     $stringDelimiter = $configuration->getConfigurationValue('TYPO3\\Flow\\Property\\TypeConverter\\ArrayConverter', self::CONFIGURATION_STRING_DELIMITER);
     if ($stringDelimiter === NULL) {
         return self::DEFAULT_STRING_DELIMITER;
     } elseif (!is_string($stringDelimiter)) {
         throw new \TYPO3\CMS\Extbase\Property\Exception\InvalidPropertyMappingConfigurationException('CONFIGURATION_STRING_DELIMITER must be of type string, "' . (is_object($stringDelimiter) ? get_class($stringDelimiter) : gettype($stringDelimiter)) . '" given', 1368433339);
     }
     return $stringDelimiter;
 }
Exemple #3
0
 /**
  * Actually convert from $source to $targetType, by doing a typecast.
  *
  * @param mixed $source
  * @param string $targetType
  * @param array $convertedChildProperties
  * @param \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration
  * @return float|\TYPO3\CMS\Extbase\Error\Error
  * @api
  */
 public function convertFrom($source, $targetType, array $convertedChildProperties = [], \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration = null)
 {
     if ($source === null || (string) $source === '') {
         return null;
     }
     // We won't backport the full flavored locale parsing of floats from Flow here
     if (is_string($source) && $configuration !== null) {
         $thousandsSeparator = $configuration->getConfigurationValue(self::class, self::CONFIGURATION_THOUSANDS_SEPARATOR);
         $decimalPoint = $configuration->getConfigurationValue(self::class, self::CONFIGURATION_DECIMAL_POINT);
         $source = str_replace($thousandsSeparator, '', $source);
         $source = str_replace($decimalPoint, '.', $source);
     }
     if (!is_numeric($source)) {
         return new \TYPO3\CMS\Extbase\Error\Error('"%s" cannot be converted to a float value.', 1332934124, [$source]);
     }
     return (double) $source;
 }
 /**
  * Import a resource and respect configuration given for properties
  *
  * @param array $uploadInfo
  * @param PropertyMappingConfigurationInterface $configuration
  * @return \TYPO3\CMS\Extbase\Domain\Model\FileReference
  * @throws TypeConverterException
  * @throws ExistingTargetFileNameException
  */
 protected function importUploadedResource(array $uploadInfo, PropertyMappingConfigurationInterface $configuration)
 {
     if (!GeneralUtility::verifyFilenameAgainstDenyPattern($uploadInfo['name'])) {
         throw new TypeConverterException('Uploading files with PHP file extensions is not allowed!', 1399312430);
     }
     $allowedFileExtensions = $configuration->getConfigurationValue('Bureauoberhoff\\H5upldr\\Property\\TypeConverter\\UploadedFileReferenceConverter', self::CONFIGURATION_ALLOWED_FILE_EXTENSIONS);
     if ($allowedFileExtensions !== NULL) {
         $filePathInfo = PathUtility::pathinfo($uploadInfo['name']);
         if (!GeneralUtility::inList($allowedFileExtensions, strtolower($filePathInfo['extension']))) {
             throw new TypeConverterException('File extension is not allowed!', 1399312430);
         }
     }
     $uploadFolderId = $configuration->getConfigurationValue('Bureauoberhoff\\H5upldr\\Property\\TypeConverter\\UploadedFileReferenceConverter', self::CONFIGURATION_UPLOAD_FOLDER) ?: $this->defaultUploadFolder;
     $conflictMode = $configuration->getConfigurationValue('Bureauoberhoff\\H5upldr\\Property\\TypeConverter\\UploadedFileReferenceConverter', self::CONFIGURATION_UPLOAD_CONFLICT_MODE) ?: $this->defaultConflictMode;
     $uploadFolder = $this->resourceFactory->retrieveFileOrFolderObject($uploadFolderId);
     $uploadedFile = $uploadFolder->addUploadedFile($uploadInfo, $conflictMode);
     $resourcePointer = isset($uploadInfo['submittedFile']['resourcePointer']) && strpos($uploadInfo['submittedFile']['resourcePointer'], 'file:') === FALSE ? $this->hashService->validateAndStripHmac($uploadInfo['submittedFile']['resourcePointer']) : NULL;
     $fileReferenceModel = $this->createFileReferenceFromFalFileObject($uploadedFile, $resourcePointer);
     return $fileReferenceModel;
 }
 /**
  * Determine the type converter to be used. If no converter has been found, an exception is raised.
  *
  * @param mixed $source
  * @param string $targetType
  * @param PropertyMappingConfigurationInterface $configuration
  * @throws Exception\TypeConverterException
  * @throws Exception\InvalidTargetException
  * @return \TYPO3\CMS\Extbase\Property\TypeConverterInterface Type Converter which should be used to convert between $source and $targetType.
  */
 protected function findTypeConverter($source, $targetType, PropertyMappingConfigurationInterface $configuration)
 {
     if ($configuration->getTypeConverter() !== null) {
         return $configuration->getTypeConverter();
     }
     $sourceType = $this->determineSourceType($source);
     if (!is_string($targetType)) {
         throw new Exception\InvalidTargetException('The target type was no string, but of type "' . gettype($targetType) . '"', 1297941727);
     }
     $targetType = $this->parseCompositeType($targetType);
     // This is needed to correctly convert old class names to new ones
     // This compatibility layer will be removed with 7.0
     $targetType = \TYPO3\CMS\Core\Core\ClassLoadingInformation::getClassNameForAlias($targetType);
     $targetType = TypeHandlingUtility::normalizeType($targetType);
     $converter = null;
     if (TypeHandlingUtility::isSimpleType($targetType)) {
         if (isset($this->typeConverters[$sourceType][$targetType])) {
             $converter = $this->findEligibleConverterWithHighestPriority($this->typeConverters[$sourceType][$targetType], $source, $targetType);
         }
     } else {
         $converter = $this->findFirstEligibleTypeConverterInObjectHierarchy($source, $sourceType, $targetType);
     }
     if ($converter === null) {
         throw new Exception\TypeConverterException('No converter found which can be used to convert from "' . $sourceType . '" to "' . $targetType . '".');
     }
     return $converter;
 }
 /**
  * Determines the target type based on the source's (optional) __type key.
  *
  * @param mixed $source
  * @param string $originalTargetType
  * @param \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration
  * @return string
  * @throws \TYPO3\CMS\Extbase\Property\Exception\InvalidDataTypeException
  * @throws \TYPO3\CMS\Extbase\Property\Exception\InvalidPropertyMappingConfigurationException
  * @throws \InvalidArgumentException
  */
 public function getTargetTypeForSource($source, $originalTargetType, \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration = null)
 {
     $targetType = $originalTargetType;
     if (is_array($source) && array_key_exists('__type', $source)) {
         $targetType = $source['__type'];
         if ($configuration === null) {
             throw new \InvalidArgumentException('A property mapping configuration must be given, not NULL.', 1326277369);
         }
         if ($configuration->getConfigurationValue(\TYPO3\CMS\Extbase\Property\TypeConverter\ObjectConverter::class, self::CONFIGURATION_OVERRIDE_TARGET_TYPE_ALLOWED) !== true) {
             throw new \TYPO3\CMS\Extbase\Property\Exception\InvalidPropertyMappingConfigurationException('Override of target type not allowed. To enable this, you need to set the PropertyMappingConfiguration Value "CONFIGURATION_OVERRIDE_TARGET_TYPE_ALLOWED" to TRUE.', 1317050430);
         }
         if ($targetType !== $originalTargetType && is_a($targetType, $originalTargetType, true) === false) {
             throw new \TYPO3\CMS\Extbase\Property\Exception\InvalidDataTypeException('The given type "' . $targetType . '" is not a subtype of "' . $originalTargetType . '".', 1317048056);
         }
     }
     return $targetType;
 }
 /**
  * @return void
  */
 public function initializeObject()
 {
     $this->mapperConfiguration->allowProperties('identifier', 'createdAt', 'lastUpdatedAt', 'title', 'subTitle', 'keywords', 'abstract', 'teaserImage');
     $this->mapperConfiguration->skipUnknownProperties();
     $this->mapperConfiguration->setMapping('_pageId', 'identifier');
     $this->mapperConfiguration->setMapping('crdate', 'createdAt');
     $this->mapperConfiguration->forProperty('createdAt')->setTypeConverterOption(DateTimeConverter::class, DateTimeConverter::CONFIGURATION_DATE_FORMAT, 'U');
     $this->mapperConfiguration->setMapping('lastUpdated', 'lastUpdatedAt');
     $this->mapperConfiguration->forProperty('lastUpdatedAt')->setTypeConverterOption(DateTimeConverter::class, DateTimeConverter::CONFIGURATION_DATE_FORMAT, 'U');
     $this->mapperConfiguration->setMapping('title', 'title');
     $this->mapperConfiguration->setMapping('subtitle', 'subTitle');
     $this->mapperConfiguration->setMapping('keywords', 'keywords');
     $this->mapperConfiguration->setMapping('abstract', 'abstract');
     $this->mapperConfiguration->setMapping('_teaserImage', 'teaserImage');
 }
Exemple #8
0
 /**
  * Determines the default date format to use for the conversion.
  * If no format is specified in the mapping configuration DEFAULT_DATE_FORMAT is used.
  *
  * @param \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration
  * @return string
  * @throws \TYPO3\CMS\Extbase\Property\Exception\InvalidPropertyMappingConfigurationException
  */
 protected function getDefaultDateFormat(\TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration = null)
 {
     if ($configuration === null) {
         return self::DEFAULT_DATE_FORMAT;
     }
     $dateFormat = $configuration->getConfigurationValue(\TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter::class, self::CONFIGURATION_DATE_FORMAT);
     if ($dateFormat === null) {
         return self::DEFAULT_DATE_FORMAT;
     } elseif ($dateFormat !== null && !is_string($dateFormat)) {
         throw new \TYPO3\CMS\Extbase\Property\Exception\InvalidPropertyMappingConfigurationException('CONFIGURATION_DATE_FORMAT must be of type string, "' . (is_object($dateFormat) ? get_class($dateFormat) : gettype($dateFormat)) . '" given', 1307719569);
     }
     return $dateFormat;
 }
Exemple #9
0
 /**
  * Handle the case if $source is an array.
  *
  * @param array $source
  * @param string $targetType
  * @param array &$convertedChildProperties
  * @param \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration
  * @return object
  * @throws \TYPO3\CMS\Extbase\Property\Exception\InvalidPropertyMappingConfigurationException
  */
 protected function handleArrayData(array $source, $targetType, array &$convertedChildProperties, \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration = null)
 {
     if (isset($source['__identity'])) {
         $object = $this->fetchObjectFromPersistence($source['__identity'], $targetType);
         if (count($source) > 1 && ($configuration === null || $configuration->getConfigurationValue(\TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::class, self::CONFIGURATION_MODIFICATION_ALLOWED) !== true)) {
             throw new \TYPO3\CMS\Extbase\Property\Exception\InvalidPropertyMappingConfigurationException('Modification of persistent objects not allowed. To enable this, you need to set the PropertyMappingConfiguration Value "CONFIGURATION_MODIFICATION_ALLOWED" to TRUE.', 1297932028);
         }
     } else {
         if ($configuration === null || $configuration->getConfigurationValue(\TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::class, self::CONFIGURATION_CREATION_ALLOWED) !== true) {
             throw new \TYPO3\CMS\Extbase\Property\Exception\InvalidPropertyMappingConfigurationException('Creation of objects not allowed. To enable this, you need to set the PropertyMappingConfiguration Value "CONFIGURATION_CREATION_ALLOWED" to TRUE', 1476044961);
         }
         $object = $this->buildObject($convertedChildProperties, $targetType);
     }
     return $object;
 }
 /**
  * Actually convert from $source to $targetType, taking into account the fully
  * built $convertedChildProperties and $configuration.
  *
  * The return value can be one of three types:
  * - an arbitrary object, or a simple type (which has been created while mapping).
  *   This is the normal case.
  * - NULL, indicating that this object should *not* be mapped (i.e. a "File Upload" Converter could return NULL if no file has been uploaded, and a silent failure should occur.
  * - An instance of \TYPO3\CMS\Extbase\Error\Error -- This will be a user-visible error message later on.
  * Furthermore, it should throw an Exception if an unexpected failure (like a security error) occurred or a configuration issue happened.
  *
  * @param mixed $source
  * @param string $targetType
  * @param array $convertedChildProperties
  * @param \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration
  *
  * @return mixed|\TYPO3\CMS\Extbase\Error\Error the target type, or an error object if a user-error occurred
  *
  * @throws \TYPO3\CMS\Extbase\Property\Exception\TypeConverterException thrown in case a developer error occurred
  */
 public function convertFrom($source, $targetType, array $convertedChildProperties = array(), \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration = null)
 {
     $alreadyPersistedImages = $configuration->getConfigurationValue('JWeiland\\Clubdirectory\\Property\\TypeConverter\\UploadMultipleFilesConverter', 'IMAGES');
     $originalSource = $source;
     foreach ($originalSource as $key => $uploadedFile) {
         // check if $source contains an uploaded file. 4 = no file uploaded
         if (!isset($uploadedFile['error']) || !isset($uploadedFile['name']) || !isset($uploadedFile['size']) || !isset($uploadedFile['tmp_name']) || !isset($uploadedFile['type']) || $uploadedFile['error'] === 4) {
             if ($alreadyPersistedImages[$key] !== null) {
                 $source[$key] = $alreadyPersistedImages[$key];
             } else {
                 unset($source[$key]);
             }
             continue;
         }
         // check if uploaded file returns an error
         if (!$uploadedFile['error'] === 0) {
             return new \TYPO3\CMS\Extbase\Error\Error(LocalizationUtility::translate('error.upload', 'clubdirectory') . $uploadedFile['error'], 1396957314);
         }
         // now we have a valid uploaded file. Check if user has rights to upload this file
         if (!isset($uploadedFile['rights']) || empty($uploadedFile['rights'])) {
             return new \TYPO3\CMS\Extbase\Error\Error(LocalizationUtility::translate('error.uploadRights', 'clubdirectory'), 1397464390);
         }
         // check if file extension is allowed
         $fileParts = GeneralUtility::split_fileref($uploadedFile['name']);
         if (!GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileParts['fileext'])) {
             return new \TYPO3\CMS\Extbase\Error\Error(LocalizationUtility::translate('error.fileExtension', 'clubdirectory', array($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'])), 1402981282);
         }
         // OK...we have a valid file and the user has the rights. It's time to check, if an old file can be deleted
         if ($alreadyPersistedImages[$key] instanceof \TYPO3\CMS\Extbase\Domain\Model\FileReference) {
             /** @var \TYPO3\CMS\Extbase\Domain\Model\FileReference $oldFile */
             $oldFile = $alreadyPersistedImages[$key];
             $oldFile->getOriginalResource()->getOriginalFile()->delete();
         }
     }
     // I will do two foreach here. First: everything must be OK, before files will be uploaded
     // upload file and add it to ObjectStorage
     /** @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage $references */
     $references = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage');
     foreach ($source as $uploadedFile) {
         if ($uploadedFile instanceof \TYPO3\CMS\Extbase\Domain\Model\FileReference) {
             $references->attach($uploadedFile);
         } else {
             $references->attach($this->getExtbaseFileReference($uploadedFile));
         }
     }
     return $references;
 }
Exemple #11
0
    /**
     * @param mixed $source
     * @param string $targetType
     * @param array $convertedChildProperties
     * @param null|\TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration
     * @return null|object|\CIC\Cicbase\Domain\Model\File|\TYPO3\CMS\Extbase\Error\Error|\TYPO3\CMS\Extbase\Error\Error
     * @throws \TYPO3\CMS\Extbase\Configuration\Exception
     */
    public function convertFrom($source, $targetType, array $convertedChildProperties = array(), \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration = NULL)
    {
        $propertyPath = $configuration->getConfigurationValue('CIC\\Cicbase\\Property\\TypeConverter\\File', 'propertyPath');
        if (!$propertyPath) {
            $propertyPath = 'file';
            $key = '';
        } else {
            $key = $propertyPath;
        }
        if (!$this->fileFactory->wasUploadAttempted($propertyPath)) {
            $fileObject = $this->fileRepository->getHeld($key);
            if ($fileObject instanceof \CIC\Cicbase\Domain\Model\File) {
                return $fileObject;
            } else {
                // this is where we end up if no file upload was attempted (eg, form was submitted without a value
                // in the upload field, and we were unable to find a held file. In this case, return false, as though
                // nothing was ever posted.
                return NULL;
                // I thought this should return an error, at first, but instead we're going to treat this as though
                // nothing was posted at all... this allows for option file upload fields, I think.
                return new \TYPO3\CMS\Extbase\Error\Error('No file was uploaded.', 1336597083);
            }
        } else {
            // Otherwise, we create a new file object. Note that we use the fileFactory to turn $_FILE data into
            // a proper file object. Elsewhere, we use the fileRepository to retrieve file objects, even those that
            // haven't yet been persisted to the database;
            $allowedTypes = $configuration->getConfigurationValue('CIC\\Cicbase\\Property\\TypeConverter\\File', 'allowedTypes');
            $maxSize = $configuration->getConfigurationValue('CIC\\Cicbase\\Property\\TypeConverter\\File', 'maxSize');
            if (!$allowedTypes) {
                $allowedTypes = $this->settings['fileAllowedMime'];
            }
            if (!$maxSize) {
                $maxSize = $this->settings['fileMaxSize'];
            }
            // Too risky to use this type converter without some settings in place.
            if (!$maxSize) {
                throw new \TYPO3\CMS\Extbase\Configuration\Exception('Before you can use the file type converter, you must set a
				 fileMaxSize value in the settings section of your extension typoscript, or in the file type converter
				 configuration.', 1337043345);
            }
            if (!is_array($allowedTypes) && count($allowedTypes) == 0) {
                throw new \TYPO3\CMS\Extbase\Configuration\Exception('Before you can use the file type converter, you must configure
				 fileAllowedMime settings section of your extension typoscript, or in the file type converter
				 configuration.', 1337043346);
            }
            $result = $this->fileFactory->createFile($source, $propertyPath, $allowedTypes, $maxSize);
            return $result;
        }
    }
Exemple #12
0
 /**
  * Import a resource and respect configuration given for properties
  *
  * @param array $uploadInfo
  * @param PropertyMappingConfigurationInterface $configuration
  * @return ExtbaseFileReference
  * @throws TypeConverterException
  */
 protected function importUploadedResource(array $uploadInfo, PropertyMappingConfigurationInterface $configuration) : ExtbaseFileReference
 {
     if (!GeneralUtility::verifyFilenameAgainstDenyPattern($uploadInfo['name'])) {
         throw new TypeConverterException('Uploading files with PHP file extensions is not allowed!', 1471710357);
     }
     $uploadFolderId = $configuration->getConfigurationValue(self::class, self::CONFIGURATION_UPLOAD_FOLDER) ?: $this->defaultUploadFolder;
     $conflictMode = $configuration->getConfigurationValue(self::class, self::CONFIGURATION_UPLOAD_CONFLICT_MODE) ?: $this->defaultConflictMode;
     $uploadFolder = $this->resourceFactory->retrieveFileOrFolderObject($uploadFolderId);
     $uploadedFile = $uploadFolder->addUploadedFile($uploadInfo, $conflictMode);
     $validators = $configuration->getConfigurationValue(self::class, self::CONFIGURATION_FILE_VALIDATORS);
     if (is_array($validators)) {
         foreach ($validators as $validator) {
             if ($validator instanceof AbstractValidator) {
                 $validationResult = $validator->validate($uploadedFile);
                 if ($validationResult->hasErrors()) {
                     $uploadedFile->getStorage()->deleteFile($uploadedFile);
                     throw new TypeConverterException($validationResult->getErrors()[0]->getMessage(), 1471708999);
                 }
             }
         }
     }
     $resourcePointer = isset($uploadInfo['submittedFile']['resourcePointer']) && strpos($uploadInfo['submittedFile']['resourcePointer'], 'file:') === false ? $this->hashService->validateAndStripHmac($uploadInfo['submittedFile']['resourcePointer']) : null;
     $fileReferenceModel = $this->createFileReferenceFromFalFileObject($uploadedFile, $resourcePointer);
     return $fileReferenceModel;
 }
 /**
  * Determines the target type based on the source's (optional) __type key.
  *
  * @param mixed $source
  * @param string $originalTargetType
  * @param \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration
  * @return string
  * @throws \TYPO3\CMS\Extbase\Property\Exception\InvalidPropertyMappingConfigurationException
  * @throws \TYPO3\CMS\Extbase\Property\Exception\InvalidDataTypeException
  * @throws \InvalidArgumentException
  */
 public function getTargetTypeForSource($source, $originalTargetType, \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration = null)
 {
     $targetType = $originalTargetType;
     if (is_array($source) && array_key_exists('__type', $source)) {
         $targetType = $source['__type'];
         if ($configuration === null) {
             throw new \InvalidArgumentException('A property mapping configuration must be given, not NULL.', 1326277369);
         }
         if ($configuration->getConfigurationValue('TYPO3\\Flow\\Property\\TypeConverter\\ObjectConverter', self::CONFIGURATION_OVERRIDE_TARGET_TYPE_ALLOWED) !== true) {
             throw new \TYPO3\CMS\Extbase\Property\Exception\InvalidPropertyMappingConfigurationException('Override of target type not allowed. To enable this, you need to set the PropertyMappingConfiguration Value "CONFIGURATION_OVERRIDE_TARGET_TYPE_ALLOWED" to TRUE.', 1317050430);
         }
         // FIXME: The following check and the checkInheritanceChainWithoutIsA() method should be removed if we raise the PHP requirement to 5.3.9 or higher
         if (version_compare(phpversion(), '5.3.8', '>')) {
             if ($targetType !== $originalTargetType && is_a($targetType, $originalTargetType, true) === false) {
                 throw new \TYPO3\CMS\Extbase\Property\Exception\InvalidDataTypeException('The given type "' . $targetType . '" is not a subtype of "' . $originalTargetType . '".', 1317048056);
             }
         } else {
             $targetType = $this->checkInheritanceChainWithoutIsA($targetType, $originalTargetType);
         }
     }
     return $targetType;
 }
    /**
     * @param mixed $source
     * @param string $targetType
     * @param array $convertedChildProperties
     * @param \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration
     * @return mixed|null|\CIC\Cicbase\Domain\Model\FileReference|\TYPO3\CMS\Extbase\Error\Error
     * @throws \TYPO3\CMS\Extbase\Configuration\Exception
     */
    public function convertFrom($source, $targetType, array $convertedChildProperties = array(), \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration = NULL)
    {
        if (is_numeric($source)) {
            return $this->fetchObjectFromPersistence($source, $targetType);
        }
        $thisClass = get_class($this);
        $propertyPath = $configuration->getConfigurationValue($thisClass, 'propertyPath');
        if (!$propertyPath) {
            $propertyPath = 'file';
            $key = '';
        } else {
            $key = $propertyPath;
        }
        if (!$this->fileFactory->wasUploadAttempted($propertyPath)) {
            $fileReference = $this->limbo->getHeld($key);
            if ($fileReference instanceof FileReference) {
                return $fileReference;
            } else {
                if (isset($source['valueIfEmpty'])) {
                    return $this->fetchObjectFromPersistence($source['valueIfEmpty'], $targetType);
                }
                return NULL;
            }
        }
        $propertyPathUnderscores = str_replace('.', '_', $propertyPath);
        $conf = $this->settings['files'][$propertyPathUnderscores];
        $allowedTypes = $configuration->getConfigurationValue($thisClass, 'allowedMimes');
        $maxSize = $configuration->getConfigurationValue($thisClass, 'maxSize');
        if (!$allowedTypes && isset($conf['allowedMimes'])) {
            $allowedTypes = $conf['allowedMimes'];
        }
        if (!$maxSize && isset($conf['maxSize'])) {
            $maxSize = $conf['maxSize'];
        }
        // Too risky to use this type converter without some settings in place.
        if (!$maxSize && (!isset($conf['dontValidateSize']) || !$conf['dontValidateSize'])) {
            throw new \TYPO3\CMS\Extbase\Configuration\Exception('Before you can use the file type converter, you must set a
			 maxSize value in the settings section of your extension typoscript, or in the file type converter
			 configuration. You can also get this error if your upload input is not named properly.', 1337043345);
        }
        if ((!is_array($allowedTypes) || count($allowedTypes) == 0) && (!isset($conf['dontValidateMime']) || !$conf['dontValidateMime'])) {
            throw new \TYPO3\CMS\Extbase\Configuration\Exception('Before you can use the file type converter, you must configure
			 allowedMimes settings section of your extension typoscript, or in the file type converter
			 configuration. You can also get this error if your upload input is not named properly.', 1337043346);
        }
        $additionalReferenceProperties = $configuration->getConfigurationValue($thisClass, 'additionalReferenceProperties');
        $reference = $this->fileFactory->createFileReference($propertyPath, $additionalReferenceProperties, $allowedTypes, $maxSize);
        return $reference;
    }