PropertyMapper
class PropertyMapper (View source)
The Property Mapper transforms simple types (arrays, strings, integers, floats, booleans) to objects or other simple types.
It is used most prominently to map incoming HTTP arguments to objects.
Properties
protected ObjectManagerInterface | $objectManager | ||
protected VariableFrontend | $cache | ||
protected array | $typeConverters | A multi-dimensional array which stores the Type Converters available in the system. |
|
protected Result | $messages | A list of property mapping messages (errors, warnings) which have occured on last mapping. |
Methods
Lifecycle method, called after all dependencies have been injected.
Returns all class names implementing the TypeConverterInterface.
Map $source to $targetType, and return the result.
Get the messages of the last Property Mapping
Internal function which actually does the property mapping.
Determine the type converter to be used. If no converter has been found, an exception is raised.
Tries to find a suitable type converter for the given source and target type.
No description
No description
Determine the type of the source data, or throw an exception if source was an unsupported format.
Collects all TypeConverter implementations in a multi-dimensional array with source and target types.
Returns a multi-dimensional array with the Type Converters available in the system.
Builds the default property mapping configuration.
Details
void
initializeObject()
Lifecycle method, called after all dependencies have been injected.
Here, the typeConverter array gets initialized.
static array
getTypeConverterImplementationClassNames(ObjectManagerInterface $objectManager)
Returns all class names implementing the TypeConverterInterface.
mixed
convert(mixed $source, string $targetType, PropertyMappingConfigurationInterface $configuration = null)
Map $source to $targetType, and return the result.
If $source is an object and already is of type $targetType, we do return the unmodified object.
Result
getMessages()
Get the messages of the last Property Mapping
protected mixed
doMapping(mixed $source, string $targetType, PropertyMappingConfigurationInterface $configuration, array $currentPropertyPath)
Internal function which actually does the property mapping.
protected TypeConverterInterface
findTypeConverter(mixed $source, string $targetType, PropertyMappingConfigurationInterface $configuration)
Determine the type converter to be used. If no converter has been found, an exception is raised.
protected mixed
findFirstEligibleTypeConverterInObjectHierarchy(string $source, string $sourceType, string $targetType)
Tries to find a suitable type converter for the given source and target type.
protected mixed
findEligibleConverterWithHighestPriority(mixed $converters, mixed $source, string $targetType)
No description
protected array
getConvertersForInterfaces(array $convertersForSource, array $interfaceNames)
No description
protected array
determineSourceTypes(mixed $source)
Determine the type of the source data, or throw an exception if source was an unsupported format.
protected array
prepareTypeConverterMap()
Collects all TypeConverter implementations in a multi-dimensional array with source and target types.
array
getTypeConverters()
Returns a multi-dimensional array with the Type Converters available in the system.
It has the following structure:
- Dimension: Source Type
- Dimension: Target Type
- Dimension: Priority Value: Type Converter instance
PropertyMappingConfiguration
buildPropertyMappingConfiguration(string $type = PropertyMappingConfiguration::class)
Builds the default property mapping configuration.