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
Afficher le fichier Open project: neos/flow-development-collection Class Usage Examples

Protected Properties

Свойство 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

Méthodes publiques

Méthode 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.

Méthodes protégées

Méthode 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 méthode

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
Résultat object The created instance

canConvertFrom() public méthode

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

convertFrom() public méthode

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
Résultat object the target type

getConstructorArgumentsForClass() protected méthode

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

getSourceChildPropertiesToBeConverted() public méthode

Convert all properties in the source array
public getSourceChildPropertiesToBeConverted ( mixed $source ) : array
$source mixed
Résultat array

getTargetTypeForSource() public méthode

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
Résultat string

getTypeOfChildProperty() public méthode

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
Résultat 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
Résultat array

$objectManager protected_oe property

protected ObjectManagerInterface,Neos\Flow\ObjectManagement $objectManager
Résultat Neos\Flow\ObjectManagement\ObjectManagerInterface

$priority protected_oe property

protected int $priority
Résultat integer

$reflectionService protected_oe property

protected ReflectionService,Neos\Flow\Reflection $reflectionService
Résultat Neos\Flow\Reflection\ReflectionService

$sourceTypes protected_oe property

protected array $sourceTypes
Résultat array

$targetType protected_oe property

protected string $targetType
Résultat string