ArrayConverter
class ArrayConverter extends AbstractTypeConverter (View source)
Converter which transforms various types to arrays.
- If the source is an array, it is returned unchanged.
- If the source is a string, is is converted depending on CONFIGURATION_STRING_FORMAT, which can be STRING_FORMAT_CSV or STRING_FORMAT_JSON. For CSV the delimiter can be set via CONFIGURATION_STRING_DELIMITER.
- If the source is a PersistentResource object, it is converted to an array. The actual resource content is either embedded as base64-encoded data or saved to a file, depending on CONFIGURATION_RESOURCE_EXPORT_TYPE. For RESOURCE_EXPORT_TYPE_FILE the setting CONFIGURATION_RESOURCE_SAVE_PATH must be set as well.
Constants
CONFIGURATION_STRING_DELIMITER |
|
DEFAULT_STRING_DELIMITER |
|
CONFIGURATION_STRING_FORMAT |
|
DEFAULT_STRING_FORMAT |
|
STRING_FORMAT_CSV |
|
STRING_FORMAT_JSON |
|
CONFIGURATION_RESOURCE_EXPORT_TYPE |
|
DEFAULT_RESOURCE_EXPORT_TYPE |
|
RESOURCE_EXPORT_TYPE_BASE64 |
|
RESOURCE_EXPORT_TYPE_FILE |
|
CONFIGURATION_RESOURCE_SAVE_PATH |
|
Properties
protected string[] | $sourceTypes | ||
protected string | $targetType | ||
protected int | $priority |
Methods
Returns the list of source types the TypeConverter can handle.
Return the target type this TypeConverter converts to.
Returns the $originalTargetType unchanged in this implementation.
Return the priority of this TypeConverter. TypeConverters with a high priority are chosen before low priority.
This implementation always returns true for this method.
Returns an empty list of sub property names
This method is never called, as getSourceChildPropertiesToBeConverted() returns an empty array.
Convert from $source to $targetType, a noop if the source is an array.
Details
string[]
getSupportedSourceTypes()
Returns the list of source types the TypeConverter can handle.
Must be PHP simple types, classes or object is not allowed.
string
getSupportedTargetType()
Return the target type this TypeConverter converts to.
Can be a simple type or a class name.
string
getTargetTypeForSource(mixed $source, string $originalTargetType, PropertyMappingConfigurationInterface $configuration = null)
Returns the $originalTargetType unchanged in this implementation.
int
getPriority()
Return the priority of this TypeConverter. TypeConverters with a high priority are chosen before low priority.
bool
canConvertFrom(mixed $source, string $targetType)
This implementation always returns true for this method.
array
getSourceChildPropertiesToBeConverted(mixed $source)
Returns an empty list of sub property names
string|null
getTypeOfChildProperty(string $targetType, string $propertyName, PropertyMappingConfigurationInterface $configuration)
This method is never called, as getSourceChildPropertiesToBeConverted() returns an empty array.
mixed|Error
convertFrom(mixed $source, string $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)
Convert from $source to $targetType, a noop if the source is an array.
If it is a string it will be converted according to the configured string format.
protected string
getStringDelimiter(PropertyMappingConfigurationInterface $configuration = null)
No description
protected string
getStringFormat(PropertyMappingConfigurationInterface $configuration = null)
No description
protected string
getResourceExportType(PropertyMappingConfigurationInterface $configuration = null)
No description