PHP Class Neos\Flow\Property\PropertyMapper

It is used most prominently to map incoming HTTP arguments to objects.
Show file Open project: neos/flow-development-collection Class Usage Examples

Protected Properties

Property Type Description
$cache Neos\Cache\Frontend\VariableFrontend
$messages Neos\Error\Messages\Result A list of property mapping messages (errors, warnings) which have occured on last mapping.
$objectManager Neos\Flow\ObjectManagement\ObjectManagerInterface
$typeConverters array It has the following structure: 1. Dimension: Source Type 2. Dimension: Target Type 3. Dimension: Priority Value: Type Converter instance

Public Methods

Method Description
buildPropertyMappingConfiguration ( string $type = PropertyMappingConfiguration::class ) : PropertyMappingConfiguration Builds the default property mapping configuration.
convert ( mixed $source, string $targetType, Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration = null ) : mixed Map $source to $targetType, and return the result.
getMessages ( ) : Neos\Error\Messages\Result Get the messages of the last Property Mapping
getTypeConverterImplementationClassNames ( Neos\Flow\ObjectManagement\ObjectManagerInterface $objectManager ) : array Returns all class names implementing the TypeConverterInterface.
getTypeConverters ( ) : array Returns a multi-dimensional array with the Type Converters available in the system.
initializeObject ( ) : void Lifecycle method, called after all dependencies have been injected.

Protected Methods

Method Description
determineSourceTypes ( mixed $source ) : array Determine the type of the source data, or throw an exception if source was an unsupported format.
doMapping ( mixed $source, string $targetType, Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration, array &$currentPropertyPath ) : mixed Internal function which actually does the property mapping.
findEligibleConverterWithHighestPriority ( mixed $converters, mixed $source, string $targetType ) : mixed
findFirstEligibleTypeConverterInObjectHierarchy ( string $source, string $sourceType, string $targetType ) : mixed Tries to find a suitable type converter for the given source and target type.
findTypeConverter ( mixed $source, string $targetType, Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration ) : Neos\Flow\Property\TypeConverterInterface Determine the type converter to be used. If no converter has been found, an exception is raised.
getConvertersForInterfaces ( array $convertersForSource, array $interfaceNames ) : array
prepareTypeConverterMap ( ) : array Collects all TypeConverter implementations in a multi-dimensional array with source and target types.

Method Details

buildPropertyMappingConfiguration() public method

Builds the default property mapping configuration.
public buildPropertyMappingConfiguration ( string $type = PropertyMappingConfiguration::class ) : PropertyMappingConfiguration
$type string the implementation class name of the PropertyMappingConfiguration to instantiate; must be a subclass of Neos\Flow\Property\PropertyMappingConfiguration
return PropertyMappingConfiguration

convert() public method

If $source is an object and already is of type $targetType, we do return the unmodified object.
public convert ( mixed $source, string $targetType, Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration = null ) : mixed
$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 Neos\Flow\Property\PropertyMappingConfigurationInterface Configuration for the property mapping. If NULL, the PropertyMappingConfigurationBuilder will create a default configuration.
return mixed an instance of $targetType

determineSourceTypes() protected method

Determine the type of the source data, or throw an exception if source was an unsupported format.
protected determineSourceTypes ( mixed $source ) : array
$source mixed
return array Possible source types (single value for simple typed source, multiple values for object source)

doMapping() protected method

Internal function which actually does the property mapping.
protected doMapping ( mixed $source, string $targetType, Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration, array &$currentPropertyPath ) : mixed
$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 Neos\Flow\Property\PropertyMappingConfigurationInterface Configuration for the property mapping.
$currentPropertyPath array The property path currently being mapped; used for knowing the context in case an exception is thrown.
return mixed an instance of $targetType

findEligibleConverterWithHighestPriority() protected method

protected findEligibleConverterWithHighestPriority ( mixed $converters, mixed $source, string $targetType ) : mixed
$converters mixed
$source mixed
$targetType string
return mixed Either the matching object converter or NULL

findFirstEligibleTypeConverterInObjectHierarchy() protected method

Tries to find a suitable type converter for the given source and target type.
protected findFirstEligibleTypeConverterInObjectHierarchy ( string $source, string $sourceType, string $targetType ) : mixed
$source string The actual source value
$sourceType string Type of the source to convert from
$targetType string Name of the target type to find a type converter for
return mixed Either the matching object converter or NULL

findTypeConverter() protected method

Determine the type converter to be used. If no converter has been found, an exception is raised.
protected findTypeConverter ( mixed $source, string $targetType, Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration ) : Neos\Flow\Property\TypeConverterInterface
$source mixed
$targetType string
$configuration Neos\Flow\Property\PropertyMappingConfigurationInterface
return Neos\Flow\Property\TypeConverterInterface Type Converter which should be used to convert between $source and $targetType.

getConvertersForInterfaces() protected method

protected getConvertersForInterfaces ( array $convertersForSource, array $interfaceNames ) : array
$convertersForSource array
$interfaceNames array
return array

getMessages() public method

Get the messages of the last Property Mapping
public getMessages ( ) : Neos\Error\Messages\Result
return Neos\Error\Messages\Result

getTypeConverterImplementationClassNames() public static method

Returns all class names implementing the TypeConverterInterface.
public static getTypeConverterImplementationClassNames ( Neos\Flow\ObjectManagement\ObjectManagerInterface $objectManager ) : array
$objectManager Neos\Flow\ObjectManagement\ObjectManagerInterface
return array Array of type converter implementations

getTypeConverters() public method

It has the following structure: 1. Dimension: Source Type 2. Dimension: Target Type 3. Dimension: Priority Value: Type Converter instance
public getTypeConverters ( ) : array
return array

initializeObject() public method

Here, the typeConverter array gets initialized.
public initializeObject ( ) : void
return void

prepareTypeConverterMap() protected method

Collects all TypeConverter implementations in a multi-dimensional array with source and target types.
See also: getTypeConverters
protected prepareTypeConverterMap ( ) : array
return array

Property Details

$cache protected property

protected VariableFrontend,Neos\Cache\Frontend $cache
return Neos\Cache\Frontend\VariableFrontend

$messages protected property

A list of property mapping messages (errors, warnings) which have occured on last mapping.
protected Result,Neos\Error\Messages $messages
return Neos\Error\Messages\Result

$objectManager protected property

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

$typeConverters protected property

It has the following structure: 1. Dimension: Source Type 2. Dimension: Target Type 3. Dimension: Priority Value: Type Converter instance
protected array $typeConverters
return array