PHP Class Neos\Flow\Property\TypeConverter\ObjectConverter

This converter will only be used on target types that are not entities or value objects (for those the PersistentObjectConverter is used). The target type can be overridden in the source by setting the __type key to the desired value. The converter will return an instance of the target type with all properties given in the source array set to the respective values. For the mechanics used to set the values see ObjectAccess::setProperty().
Inheritance: extends AbstractTypeConverter
Mostra file Open project: neos/flow-development-collection Class Usage Examples

Protected Properties

Property Type Description
$constructorReflectionFirstLevelCache array As it is very likely that the constructor arguments are needed twice we should cache them for the request.
$objectManager Neos\Flow\ObjectManagement\ObjectManagerInterface
$priority integer
$reflectionService Neos\Flow\Reflection\ReflectionService
$sourceTypes array
$targetType string

Public Methods

Method Description
canConvertFrom ( mixed $source, string $targetType ) : boolean Only convert non-persistent types
convertFrom ( mixed $source, string $targetType, array $convertedChildProperties = [], Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration = null ) : object Convert an object from $source to an object.
getSourceChildPropertiesToBeConverted ( mixed $source ) : array Convert all properties in the source array
getTargetTypeForSource ( mixed $source, string $originalTargetType, Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration = null ) : string Determines the target type based on the source's (optional) __type key.
getTypeOfChildProperty ( string $targetType, string $propertyName, Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration ) : string The type of a property is determined by the reflection service.

Protected Methods

Method Description
buildObject ( array &$possibleConstructorArgumentValues, string $objectType ) : object Builds a new instance of $objectType with the given $possibleConstructorArgumentValues.
getConstructorArgumentsForClass ( string $className ) : array Get the constructor argument reflection for the given object type.

Method Details

buildObject() protected method

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
protected buildObject ( array &$possibleConstructorArgumentValues, string $objectType ) : object
$possibleConstructorArgumentValues array
$objectType string
return object The created instance

canConvertFrom() public method

Only convert non-persistent types
public canConvertFrom ( mixed $source, string $targetType ) : boolean
$source mixed
$targetType string
return boolean

convertFrom() public method

Convert an object from $source to an object.
public convertFrom ( mixed $source, string $targetType, array $convertedChildProperties = [], Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration = null ) : object
$source mixed
$targetType string
$convertedChildProperties array
$configuration Neos\Flow\Property\PropertyMappingConfigurationInterface
return object the target type

getConstructorArgumentsForClass() protected method

Get the constructor argument reflection for the given object type.
protected getConstructorArgumentsForClass ( string $className ) : array
$className string
return array

getSourceChildPropertiesToBeConverted() public method

Convert all properties in the source array
public getSourceChildPropertiesToBeConverted ( mixed $source ) : array
$source mixed
return array

getTargetTypeForSource() public method

Determines the target type based on the source's (optional) __type key.
public getTargetTypeForSource ( mixed $source, string $originalTargetType, Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration = null ) : string
$source mixed
$originalTargetType string
$configuration Neos\Flow\Property\PropertyMappingConfigurationInterface
return string

getTypeOfChildProperty() public method

The type of a property is determined by the reflection service.
public getTypeOfChildProperty ( string $targetType, string $propertyName, Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration ) : string
$targetType string
$propertyName string
$configuration Neos\Flow\Property\PropertyMappingConfigurationInterface
return string

Property Details

$constructorReflectionFirstLevelCache protected_oe property

As it is very likely that the constructor arguments are needed twice we should cache them for the request.
protected array $constructorReflectionFirstLevelCache
return array

$objectManager protected_oe property

protected ObjectManagerInterface,Neos\Flow\ObjectManagement $objectManager
return Neos\Flow\ObjectManagement\ObjectManagerInterface

$priority protected_oe property

protected int $priority
return integer

$reflectionService protected_oe property

protected ReflectionService,Neos\Flow\Reflection $reflectionService
return Neos\Flow\Reflection\ReflectionService

$sourceTypes protected_oe property

protected array $sourceTypes
return array

$targetType protected_oe property

protected string $targetType
return string