PropertyMapper
class \
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.
Attributes
- #[Autoconfigure]
- $public: true
Table of Contents
Properties
- $configurationBuilder : PropertyMappingConfigurationBuilder
- $messages : Result
- A list of property mapping messages (errors, warnings) which have occurred on last mapping.
- $typeConverterRegistry : TypeConverterRegistry
Methods
- __construct() : mixed
- convert() : mixed
- Map $source to $targetType, and return the result
- getMessages() : Result
- Get the messages of the last Property Mapping.
- resetMessages() : void
- Resets the messages of the last Property Mapping.
- determineSourceType() : string
- Determine the type of the source data, or throw an exception if source was an unsupported format.
- doMapping() : mixed
- Internal function which actually does the property mapping.
- findTypeConverter() : TypeConverterInterface
- Determine the type converter to be used. If no converter has been found, an exception is raised.
- parseCompositeType() : string
- Parse a composite type like \Foo\Collection<\Bar\Entity> into \Foo\Collection
Properties
$configurationBuilder
protected
PropertyMappingConfigurationBuilder
$configurationBuilder
$messages
A list of property mapping messages (errors, warnings) which have occurred on last mapping.
protected
Result
$messages
$typeConverterRegistry
protected
TypeConverterRegistry
$typeConverterRegistry
Methods
__construct()
public
__construct(TypeConverterRegistry $typeConverterRegistry, PropertyMappingConfigurationBuilder $configurationBuilder) : mixed
Parameters
- $typeConverterRegistry : TypeConverterRegistry
- $configurationBuilder : PropertyMappingConfigurationBuilder
convert()
Map $source to $targetType, and return the result
public
convert(mixed $source, string $targetType[, PropertyMappingConfigurationInterface|null $configuration = null ]) : mixed
Parameters
- $source : mixed
-
the source data to map. MUST be a simple type, NO object allowed!
- $targetType : string
-
The type of the target; can be either a class name or a simple type.
- $configuration : PropertyMappingConfigurationInterface|null = null
-
Configuration for the property mapping. If NULL, the PropertyMappingConfigurationBuilder will create a default configuration.
Return values
mixed —an instance of $targetType
getMessages()
Get the messages of the last Property Mapping.
public
getMessages() : Result
Return values
ResultresetMessages()
Resets the messages of the last Property Mapping.
public
resetMessages() : void
determineSourceType()
Determine the type of the source data, or throw an exception if source was an unsupported format.
protected
determineSourceType(mixed $source) : string
Parameters
- $source : mixed
Internal
since TYPO3 v12.0
Tags
Return values
stringdoMapping()
Internal function which actually does the property mapping.
protected
doMapping(mixed $source, string $targetType, PropertyMappingConfigurationInterface $configuration, array &$currentPropertyPath) : mixed
Parameters
- $source : mixed
-
the source data to map. MUST be a simple type, NO object allowed!
- $targetType : string
-
The type of the target; can be either a class name or a simple type.
- $configuration : PropertyMappingConfigurationInterface
-
Configuration for the property mapping.
- $currentPropertyPath : array
-
The property path currently being mapped; used for knowing the context in case an exception is thrown.
Internal
since TYPO3 v12.0
Return values
mixed —an instance of $targetType
findTypeConverter()
Determine the type converter to be used. If no converter has been found, an exception is raised.
protected
findTypeConverter(mixed $source, string $targetType, PropertyMappingConfigurationInterface $configuration) : TypeConverterInterface
Parameters
- $source : mixed
- $targetType : string
- $configuration : PropertyMappingConfigurationInterface
Internal
since TYPO3 v12.0
Tags
Return values
TypeConverterInterface —Type Converter which should be used to convert between $source and $targetType.
parseCompositeType()
Parse a composite type like \Foo\Collection<\Bar\Entity> into \Foo\Collection
protected
parseCompositeType(string $compositeType) : string
Parameters
- $compositeType : string
Internal
since TYPO3 v12.0