PHP Класс 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).
Показать файл
Открыть проект
Примеры использования класса
Защищенные свойства (Protected)
Открытые методы
Метод |
Описание |
|
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. |
|
Защищенные методы
Метод |
Описание |
|
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 |
|
|
Описание методов
convertFrom()
публичный Метод
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 |
|
Результат |
PersistentResource | Neos\Error\Messages\Error |
if the input format is not supported or could not be converted for other reasons |
getCollectionName()
защищенный Метод
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 |
|
Результат |
string |
|
handleFileUploads()
защищенный Метод
protected handleFileUploads ( array $source, Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration = null ) : PersistentResource | Neos\Error\Messages\Error |
$source |
array |
|
$configuration |
Neos\Flow\Property\PropertyMappingConfigurationInterface |
|
Результат |
PersistentResource | Neos\Error\Messages\Error |
|
handleHashAndData()
защищенный Метод
protected handleHashAndData ( array $source, Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration = null ) : PersistentResource | Neos\Error\Messages\Error |
$source |
array |
|
$configuration |
Neos\Flow\Property\PropertyMappingConfigurationInterface |
|
Результат |
PersistentResource | Neos\Error\Messages\Error |
|
Описание свойств
$convertedResources защищенное свойство
protected array $convertedResources |
Результат |
array |
|
$persistenceManager защищенное свойство
protected PersistenceManagerInterface,Neos\Flow\Persistence $persistenceManager |
Результат |
Neos\Flow\Persistence\PersistenceManagerInterface |
|
$priority защищенное свойство
protected int $priority |
Результат |
integer |
|
$resourceManager защищенное свойство
protected ResourceManager,Neos\Flow\ResourceManagement $resourceManager |
Результат |
ResourceManager |
|
$resourceRepository защищенное свойство
protected ResourceRepository,Neos\Flow\ResourceManagement $resourceRepository |
Результат |
ResourceRepository |
|
$sourceTypes защищенное свойство
protected array $sourceTypes |
Результат |
array |
|
$systemLogger защищенное свойство
protected SystemLoggerInterface,Neos\Flow\Log $systemLogger |
Результат |
Neos\Flow\Log\SystemLoggerInterface |
|
$targetType защищенное свойство
protected string $targetType |
Результат |
string |
|