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

Public Member Functions

 injectObjectManager (ObjectManagerInterface $objectManager)
 
 injectConfigurationBuilder (PropertyMappingConfigurationBuilder $configurationBuilder)
 
 initializeObject ()
 
mixed convert ($source, $targetType, PropertyMappingConfigurationInterface $configuration=null)
 
TYPO3 CMS Extbase Error Result getMessages ()
 
string parseCompositeType ($compositeType)
 

Protected Member Functions

mixed doMapping ($source, $targetType, PropertyMappingConfigurationInterface $configuration, &$currentPropertyPath)
 
TYPO3 CMS Extbase Property TypeConverterInterface findTypeConverter ($source, $targetType, PropertyMappingConfigurationInterface $configuration)
 
mixed findFirstEligibleTypeConverterInObjectHierarchy ($source, $sourceType, $targetClass)
 
mixed findEligibleConverterWithHighestPriority ($converters, $source, $targetType)
 
array getConvertersForInterfaces (array $convertersForSource, array $interfaceNames)
 
string determineSourceType ($source)
 

Protected Attributes

TYPO3 CMS Extbase Object ObjectManagerInterface $objectManager
 
TYPO3 CMS Extbase Property PropertyMappingConfigurationBuilder $configurationBuilder
 
array $typeConverters = array( )
 
TYPO3 CMS Extbase Error 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 36 of file PropertyMapper.php.

Member Function Documentation

◆ convert()

mixed TYPO3\CMS\Extbase\Property\PropertyMapper::convert (   $source,
  $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$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 110 of file PropertyMapper.php.

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

◆ determineSourceType()

string 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 364 of file PropertyMapper.php.

◆ doMapping()

mixed TYPO3\CMS\Extbase\Property\PropertyMapper::doMapping (   $source,
  $targetType,
PropertyMappingConfigurationInterface  $configuration,
$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.
Exceptions
Exception

Definition at line 152 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().

◆ findEligibleConverterWithHighestPriority()

mixed TYPO3\CMS\Extbase\Property\PropertyMapper::findEligibleConverterWithHighestPriority (   $converters,
  $source,
  $targetType 
)
protected
Parameters
mixed$converters
mixed$source
string$targetType
Returns
‪mixed Either the matching object converter or NULL

Definition at line 318 of file PropertyMapper.php.

◆ findFirstEligibleTypeConverterInObjectHierarchy()

mixed TYPO3\CMS\Extbase\Property\PropertyMapper::findFirstEligibleTypeConverterInObjectHierarchy (   $source,
  $sourceType,
  $targetClass 
)
protected

Tries to find a suitable type converter for the given source and target type.

Parameters
string$source‪The actual source value
string$sourceType‪Type of the source to convert from
string$targetClass‪Name of the target class to find a type converter for
Returns
‪mixed Either the matching object converter or NULL
Exceptions
Exception

Definition at line 268 of file PropertyMapper.php.

◆ findTypeConverter()

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

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

Parameters
mixed$source
string$targetType
PropertyMappingConfigurationInterface$configuration
Exceptions
Exception

Definition at line 220 of file PropertyMapper.php.

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

◆ getConvertersForInterfaces()

array TYPO3\CMS\Extbase\Property\PropertyMapper::getConvertersForInterfaces ( array  $convertersForSource,
array  $interfaceNames 
)
protected
Parameters
array$convertersForSource
array$interfaceNames
Returns
‪array
Exceptions
Exception

Definition at line 341 of file PropertyMapper.php.

◆ getMessages()

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

Get the messages of the last Property Mapping

Returns
‪\TYPO3\CMS\Extbase\Error\Result

Definition at line 136 of file PropertyMapper.php.

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

◆ initializeObject()

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

Lifecycle method, called after all dependencies have been injected. Here, the typeConverter array gets initialized.

Exceptions
Exception

Definition at line 88 of file PropertyMapper.php.

References $GLOBALS.

◆ injectConfigurationBuilder()

TYPO3\CMS\Extbase\Property\PropertyMapper::injectConfigurationBuilder ( PropertyMappingConfigurationBuilder  $configurationBuilder)
Parameters
\TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationBuilder$configurationBuilder

only to be used within Extbase, not part of TYPO3 Core API.

Definition at line 76 of file PropertyMapper.php.

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

◆ injectObjectManager()

TYPO3\CMS\Extbase\Property\PropertyMapper::injectObjectManager ( ObjectManagerInterface  $objectManager)
Parameters
\TYPO3\CMS\Extbase\Object\ObjectManagerInterface$objectManager

only to be used within Extbase, not part of TYPO3 Core API.

Definition at line 67 of file PropertyMapper.php.

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

◆ parseCompositeType()

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

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

Parameters
string$compositeType
Returns
‪string

only to be used within Extbase, not part of TYPO3 Core API.

Definition at line 392 of file PropertyMapper.php.

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

Member Data Documentation

◆ $configurationBuilder

TYPO3 CMS Extbase Property PropertyMappingConfigurationBuilder TYPO3\CMS\Extbase\Property\PropertyMapper::$configurationBuilder
protected

◆ $messages

TYPO3 CMS Extbase Error 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 61 of file PropertyMapper.php.

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

◆ $objectManager

TYPO3 CMS Extbase Object ObjectManagerInterface TYPO3\CMS\Extbase\Property\PropertyMapper::$objectManager
protected

◆ $typeConverters

array TYPO3\CMS\Extbase\Property\PropertyMapper::$typeConverters = array( )
protected

A multi-dimensional array which stores the Type Converters available in the system. It has the following structure:

  1. ‪Dimension: Source Type
  2. ‪Dimension: Target Type
  3. ‪Dimension: Priority Value: Type Converter instance

Definition at line 55 of file PropertyMapper.php.