PropertyMapper implements SingletonInterface

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.

Table of Contents

Interfaces

SingletonInterface
"empty" interface for singletons (marker interface pattern)

Properties

$configurationBuilder  : PropertyMappingConfigurationBuilder
$container  : ContainerInterface
$messages  : Result
A list of property mapping messages (errors, warnings) which have occurred on last mapping.
$typeConverters  : array<string|int, mixed>
A multi-dimensional array which stores the Type Converters available in the system.

Methods

__construct()  : mixed
convert()  : mixed
Map $source to $targetType, and return the result
getMessages()  : Result
Get the messages of the last Property Mapping.
initializeObject()  : mixed
Lifecycle method, called after all dependencies have been injected.
parseCompositeType()  : string
Parse a composite type like \Foo\Collection<\Bar\Entity> into \Foo\Collection
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.
findEligibleConverterWithHighestPriority()  : mixed
findFirstEligibleTypeConverterInObjectHierarchy()  : mixed
Tries to find a suitable type converter for the given source and target type.
findTypeConverter()  : TypeConverterInterface
Determine the type converter to be used. If no converter has been found, an exception is raised.
getConvertersForInterfaces()  : array<string|int, mixed>

Properties

$container

protected ContainerInterface $container

$messages

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

protected Result $messages

$typeConverters

A multi-dimensional array which stores the Type Converters available in the system.

protected array<string|int, mixed> $typeConverters = []

It has the following structure:

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

Methods

convert()

Map $source to $targetType, and return the result

public convert(mixed $source, string $targetType[, PropertyMappingConfigurationInterface $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

Configuration for the property mapping. If NULL, the PropertyMappingConfigurationBuilder will create a default configuration.

Tags
throws
Exception
Return values
mixed

an instance of $targetType

getMessages()

Get the messages of the last Property Mapping.

public getMessages() : Result
Return values
Result

initializeObject()

Lifecycle method, called after all dependencies have been injected.

public initializeObject() : mixed

Here, the typeConverter array gets initialized.

Internal

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

Tags
throws
DuplicateTypeConverterException

parseCompositeType()

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

public parseCompositeType(string $compositeType) : string
Parameters
$compositeType : string
Internal

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

Return values
string

resetMessages()

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
Tags
throws
InvalidSourceException
Return values
string

the type of $source

doMapping()

Internal function which actually does the property mapping.

protected doMapping(mixed $source, string $targetType, PropertyMappingConfigurationInterface $configuration, array<string|int, mixed> &$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<string|int, mixed>

The property path currently being mapped; used for knowing the context in case an exception is thrown.

Tags
throws
TypeConverterException
throws
InvalidPropertyMappingConfigurationException
Return values
mixed

an instance of $targetType

findEligibleConverterWithHighestPriority()

protected findEligibleConverterWithHighestPriority(mixed $converters, mixed $source, string $targetType) : mixed
Parameters
$converters : mixed
$source : mixed
$targetType : string
Return values
mixed

Either the matching object converter or NULL

findFirstEligibleTypeConverterInObjectHierarchy()

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

protected findFirstEligibleTypeConverterInObjectHierarchy(string $source, string $sourceType, string $targetClass) : mixed
Parameters
$source : string

The actual source value

$sourceType : string

Type of the source to convert from

$targetClass : string

Name of the target class to find a type converter for

Tags
throws
InvalidTargetException
Return values
mixed

Either the matching object converter or NULL

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
Tags
throws
TypeConverterException
throws
InvalidTargetException
Return values
TypeConverterInterface

Type Converter which should be used to convert between $source and $targetType.

getConvertersForInterfaces()

protected getConvertersForInterfaces(array<string|int, mixed> $convertersForSource, array<string|int, mixed> $interfaceNames) : array<string|int, mixed>
Parameters
$convertersForSource : array<string|int, mixed>
$interfaceNames : array<string|int, mixed>
Tags
throws
DuplicateTypeConverterException
Return values
array<string|int, mixed>

        
On this page

Search results