‪TYPO3CMS  ‪main
TYPO3\CMS\Extbase\Property\PropertyMapper Class Reference
Inheritance diagram for TYPO3\CMS\Extbase\Property\PropertyMapper:
TYPO3\CMS\Core\SingletonInterface

Public Member Functions

 __construct (protected TypeConverterRegistry $typeConverterRegistry, protected PropertyMappingConfigurationBuilder $configurationBuilder)
 
mixed convert ($source, string $targetType, ?PropertyMappingConfigurationInterface $configuration=null)
 
 getMessages ()
 
 resetMessages ()
 

Protected Member Functions

mixed doMapping ($source, string $targetType, PropertyMappingConfigurationInterface $configuration, array &$currentPropertyPath)
 
TypeConverterInterface findTypeConverter ($source, string $targetType, PropertyMappingConfigurationInterface $configuration)
 
 determineSourceType ($source)
 
 parseCompositeType (string $compositeType)
 

Protected Attributes

Result $messages
 

Detailed Description

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.

Definition at line 29 of file PropertyMapper.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Extbase\Property\PropertyMapper::__construct ( protected TypeConverterRegistry  $typeConverterRegistry,
protected PropertyMappingConfigurationBuilder  $configurationBuilder 
)

Member Function Documentation

◆ convert()

mixed TYPO3\CMS\Extbase\Property\PropertyMapper::convert (   $source,
string  $targetType,
?PropertyMappingConfigurationInterface  $configuration = null 
)

Map $source to $targetType, and return the result

Parameters
mixed$source‪the source data to map. MUST be a simple type, NO object allowed!
string$targetType‪The type of the target; can be either a class name or a simple type.
PropertyMappingConfigurationInterface | null$configurationConfiguration for the property mapping. If NULL, the PropertyMappingConfigurationBuilder will create a default configuration.
Exceptions
Exception
Returns
‪mixed an instance of $targetType

Definition at line 52 of file PropertyMapper.php.

References TYPO3\CMS\Extbase\Property\PropertyMapper\doMapping().

◆ determineSourceType()

TYPO3\CMS\Extbase\Property\PropertyMapper::determineSourceType (   $source)
protected

Determine the type of the source data, or throw an exception if source was an unsupported format.

Parameters
mixed$source
Exceptions
Exception

Definition at line 188 of file PropertyMapper.php.

◆ doMapping()

mixed TYPO3\CMS\Extbase\Property\PropertyMapper::doMapping (   $source,
string  $targetType,
PropertyMappingConfigurationInterface  $configuration,
array &  $currentPropertyPath 
)
protected

Internal function which actually does the property mapping.

Parameters
mixed$source‪the source data to map. MUST be a simple type, NO object allowed!
string$targetType‪The type of the target; can be either a class name or a simple type.
PropertyMappingConfigurationInterface$configurationConfiguration for the property mapping.
array$currentPropertyPath‪The property path currently being mapped; used for knowing the context in case an exception is thrown.
Returns
‪mixed an instance of $targetType
Exceptions
Exception

Definition at line 105 of file PropertyMapper.php.

References TYPO3\CMS\Extbase\Property\PropertyMapper\findTypeConverter(), TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface\getTargetPropertyName(), TYPO3\CMS\Extbase\Property\PropertyMapper\parseCompositeType(), TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface\shouldSkip(), and TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface\shouldSkipUnknownProperties().

Referenced by TYPO3\CMS\Extbase\Property\PropertyMapper\convert().

◆ findTypeConverter()

TypeConverterInterface TYPO3\CMS\Extbase\Property\PropertyMapper::findTypeConverter (   $source,
string  $targetType,
PropertyMappingConfigurationInterface  $configuration 
)
protected

Determine the type converter to be used. If no converter has been found, an exception is raised.

Parameters
mixed$source
Returns
TypeConverterInterface Type Converter which should be used to convert between $source and $targetType.
Exceptions
Exception

Definition at line 166 of file PropertyMapper.php.

Referenced by TYPO3\CMS\Extbase\Property\PropertyMapper\doMapping().

◆ getMessages()

TYPO3\CMS\Extbase\Property\PropertyMapper::getMessages ( )

Get the messages of the last Property Mapping.

Definition at line 73 of file PropertyMapper.php.

References TYPO3\CMS\Extbase\Property\PropertyMapper\$messages.

◆ parseCompositeType()

TYPO3\CMS\Extbase\Property\PropertyMapper::parseCompositeType ( string  $compositeType)
protected

Parse a composite type like \Foo\Collection<\Bar\Entity> into \Foo\Collection

since TYPO3 v12.0

Definition at line 214 of file PropertyMapper.php.

Referenced by TYPO3\CMS\Extbase\Property\PropertyMapper\doMapping().

◆ resetMessages()

TYPO3\CMS\Extbase\Property\PropertyMapper::resetMessages ( )

Resets the messages of the last Property Mapping.

Definition at line 81 of file PropertyMapper.php.

Referenced by TYPO3\CMS\Extbase\Property\PropertyMapper\__construct().

Member Data Documentation

◆ $messages

Result TYPO3\CMS\Extbase\Property\PropertyMapper::$messages
protected

A list of property mapping messages (errors, warnings) which have occurred on last mapping.

Definition at line 34 of file PropertyMapper.php.

Referenced by TYPO3\CMS\Extbase\Property\PropertyMapper\getMessages().