PHP Class Neos\Flow\ResourceManagement\ResourceTypeConverter

Has two major working modes: 1. File Uploads by PHP In this case, the input array is expected to be a fresh file upload following the native PHP handling. The temporary upload file is then imported through the resource manager. To enable the handling of files that have already been uploaded earlier, the special field ['originallySubmittedResource'] is checked. If set, it is used to fetch a file that has already been uploaded even if no file has been actually uploaded in the current request. 2. Strings / arbitrary Arrays If the source - is an array and contains the key '__identity' the converter will find an existing resource with the given identity or continue and assign the given identity if CONFIGURATION_IDENTITY_CREATION_ALLOWED is set. - is a string looking like a SHA1 (40 characters [0-9a-f]) or - is an array and contains the key 'hash' with a value looking like a SHA1 (40 characters [0-9a-f]) the converter will look up an existing PersistentResource with that hash and return it if found. If that fails, the converter will try to import a file named like that hash from the configured CONFIGURATION_RESOURCE_LOAD_PATH. If no hash is given in an array source but the key 'data' is set, the content of that key is assumed a binary string and a PersistentResource representing this content is created and returned. The imported PersistentResource will be given a 'filename' if set in the source array in both cases (import from file or data).
Inheritance: extends Neos\Flow\Property\TypeConverter\AbstractTypeConverter
Datei anzeigen Open project: neos/flow-development-collection Class Usage Examples

Protected Properties

Property Type Description
$convertedResources array
$persistenceManager Neos\Flow\Persistence\PersistenceManagerInterface
$priority integer
$resourceManager ResourceManager
$resourceRepository ResourceRepository
$sourceTypes array
$systemLogger Neos\Flow\Log\SystemLoggerInterface
$targetType string

Public Methods

Method Description
convertFrom ( array $source, string $targetType, array $convertedChildProperties = [], Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration = null ) : PersistentResource | Neos\Error\Messages\Error Converts the given string or array to a PersistentResource object.

Protected Methods

Method Description
getCollectionName ( array $source, Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration = null ) : string Get the collection name this resource will be stored in. Default will be ResourceManager::DEFAULT_PERSISTENT_COLLECTION_NAME The propertyMappingConfiguration CONFIGURATION_COLLECTION_NAME will directly override the default. Then if CONFIGURATION_ALLOW_COLLECTION_OVERRIDE is TRUE and __collectionName is in the $source this will finally be the value.
handleFileUploads ( array $source, Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration = null ) : PersistentResource | Neos\Error\Messages\Error
handleHashAndData ( array $source, Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration = null ) : PersistentResource | Neos\Error\Messages\Error

Method Details

convertFrom() public method

If the input format is an array, this method assumes the resource to be a fresh file upload and imports the temporary upload file through the ResourceManager. Note that $source['error'] will also be present if a file was successfully uploaded. In that case its value will be \UPLOAD_ERR_OK.
public convertFrom ( array $source, string $targetType, array $convertedChildProperties = [], Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration = null ) : PersistentResource | Neos\Error\Messages\Error
$source array The upload info (expected keys: error, name, tmp_name)
$targetType string
$convertedChildProperties array
$configuration Neos\Flow\Property\PropertyMappingConfigurationInterface
return PersistentResource | Neos\Error\Messages\Error if the input format is not supported or could not be converted for other reasons

getCollectionName() protected method

Get the collection name this resource will be stored in. Default will be ResourceManager::DEFAULT_PERSISTENT_COLLECTION_NAME The propertyMappingConfiguration CONFIGURATION_COLLECTION_NAME will directly override the default. Then if CONFIGURATION_ALLOW_COLLECTION_OVERRIDE is TRUE and __collectionName is in the $source this will finally be the value.
protected getCollectionName ( array $source, Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration = null ) : string
$source array
$configuration Neos\Flow\Property\PropertyMappingConfigurationInterface
return string

handleFileUploads() protected method

protected handleFileUploads ( array $source, Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration = null ) : PersistentResource | Neos\Error\Messages\Error
$source array
$configuration Neos\Flow\Property\PropertyMappingConfigurationInterface
return PersistentResource | Neos\Error\Messages\Error

handleHashAndData() protected method

protected handleHashAndData ( array $source, Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration = null ) : PersistentResource | Neos\Error\Messages\Error
$source array
$configuration Neos\Flow\Property\PropertyMappingConfigurationInterface
return PersistentResource | Neos\Error\Messages\Error

Property Details

$convertedResources protected_oe property

protected array $convertedResources
return array

$persistenceManager protected_oe property

protected PersistenceManagerInterface,Neos\Flow\Persistence $persistenceManager
return Neos\Flow\Persistence\PersistenceManagerInterface

$priority protected_oe property

protected int $priority
return integer

$resourceManager protected_oe property

protected ResourceManager,Neos\Flow\ResourceManagement $resourceManager
return ResourceManager

$resourceRepository protected_oe property

protected ResourceRepository,Neos\Flow\ResourceManagement $resourceRepository
return ResourceRepository

$sourceTypes protected_oe property

protected array $sourceTypes
return array

$systemLogger protected_oe property

protected SystemLoggerInterface,Neos\Flow\Log $systemLogger
return Neos\Flow\Log\SystemLoggerInterface

$targetType protected_oe property

protected string $targetType
return string