ObjectConverter

class \TYPO3\CMS\Extbase\Property\TypeConverter\ObjectConverter

Extends
AbstractTypeConverter

This converter transforms arrays to simple objects (POPO) by setting properties.

Table of Contents

Constants

CONFIGURATION_OVERRIDE_TARGET_TYPE_ALLOWED  : int = 4
CONFIGURATION_TARGET_TYPE  : int = 3

Properties

$container  : ContainerInterface
$reflectionService  : ReflectionService

Methods

convertFrom()  : object|null
Convert an object from $source to an object.
getSourceChildPropertiesToBeConverted()  : array
Convert all properties in the source array
getTargetTypeForSource()  : string
Determines the target type based on the source's (optional) __type key and by evaluating possible XCLASS overrides of the target type.
getTypeOfChildProperty()  : string
The type of a property is determined by the reflection service.
injectContainer()  : void
injectReflectionService()  : void
buildObject()  : object
Builds a new instance of $objectType with the given $possibleConstructorArgumentValues. If constructor argument values are missing from the given array the method looks for a default value in the constructor signature. Furthermore, the constructor arguments are removed from $possibleConstructorArgumentValues: They are considered "handled" by __construct and will not be mapped calling setters later.

Constants

CONFIGURATION_OVERRIDE_TARGET_TYPE_ALLOWED

public int CONFIGURATION_OVERRIDE_TARGET_TYPE_ALLOWED = 4

CONFIGURATION_TARGET_TYPE

public int CONFIGURATION_TARGET_TYPE = 3

Properties

$container

protected ContainerInterface $container

Methods

convertFrom()

Convert an object from $source to an object.

public convertFrom(mixed $source, string $targetType[, array $convertedChildProperties = [] ][, PropertyMappingConfigurationInterface|null $configuration = null ]) : object|null

Parameters

$source : mixed
$targetType : string
$convertedChildProperties : array = []
$configuration : PropertyMappingConfigurationInterface|null = null

Tags

throws
InvalidTargetException

Return values

object|null —

the target type

getSourceChildPropertiesToBeConverted()

Convert all properties in the source array

public getSourceChildPropertiesToBeConverted(mixed $source) : array

Parameters

$source : mixed

Return values

array

getTargetTypeForSource()

Determines the target type based on the source's (optional) __type key and by evaluating possible XCLASS overrides of the target type.

public getTargetTypeForSource(mixed $source, string $originalTargetType[, PropertyMappingConfigurationInterface|null $configuration = null ]) : string

Parameters

$source : mixed
$originalTargetType : string

the type we originally want to convert to

$configuration : PropertyMappingConfigurationInterface|null = null

Tags

throws
InvalidDataTypeException
throws
InvalidPropertyMappingConfigurationException
throws
InvalidArgumentException

Return values

string

getTypeOfChildProperty()

The type of a property is determined by the reflection service.

public getTypeOfChildProperty(string $targetType, string $propertyName, PropertyMappingConfigurationInterface $configuration) : string

Parameters

$targetType : string
$propertyName : string
$configuration : PropertyMappingConfigurationInterface

Tags

throws
InvalidTargetException

Return values

string —

the type of $propertyName in $targetType

injectContainer()

public injectContainer(ContainerInterface $container) : void

Parameters

$container : ContainerInterface

buildObject()

Builds a new instance of $objectType with the given $possibleConstructorArgumentValues. If constructor argument values are missing from the given array the method looks for a default value in the constructor signature. Furthermore, the constructor arguments are removed from $possibleConstructorArgumentValues: They are considered "handled" by __construct and will not be mapped calling setters later.

protected buildObject(array &$possibleConstructorArgumentValues, string $objectType) : object

Parameters

$possibleConstructorArgumentValues : array
$objectType : string

Tags

throws
InvalidTargetException

if a required constructor argument is missing

Return values

object —

The created instance

On this page