class MvcPropertyMappingConfiguration extends PropertyMappingConfiguration (View source)

The default property mapping configuration is available inside the Argument-object.

Constants

PROPERTY_PATH_PLACEHOLDER

Placeholder in property paths for multi-valued types

Properties

protected array $configuration

multi-dimensional array which stores type-converter specific configuration:

  1. Dimension: Fully qualified class name of the type converter
  2. Dimension: Configuration Key Value: Configuration Value
from  PropertyMappingConfiguration
protected PropertyMappingConfiguration[] $subConfigurationForProperty

Stores the configuration for specific child properties.

from  PropertyMappingConfiguration
protected array $mapping

Keys which should be renamed

from  PropertyMappingConfiguration
protected TypeConverterInterface $typeConverter from  PropertyMappingConfiguration
protected array $propertiesToBeMapped

List of allowed property names to be converted

from  PropertyMappingConfiguration
protected array $propertiesToSkip

List of property names to be skipped during property mapping

from  PropertyMappingConfiguration
protected array $propertiesNotToBeMapped

List of disallowed property names which will be ignored while property mapping

from  PropertyMappingConfiguration
protected bool $skipUnknownProperties

If true, unknown properties will be skipped during property mapping

from  PropertyMappingConfiguration
protected bool $mapUnknownProperties

If true, unknown properties will be mapped.

from  PropertyMappingConfiguration

Methods

bool
shouldMap(string $propertyName)

The behavior is as follows:

bool
shouldSkip(string $propertyName)

Check if the given $propertyName should be skipped during mapping.

allowAllProperties()

Allow all properties in property mapping, even unknown ones.

allowProperties(string ...$propertyNames)

Allow a list of specific properties. All arguments of allowProperties are used here (varargs).

skipProperties(string ...$propertyNames)

Skip a list of specific properties. All arguments of skipProperties are used here (varargs).

allowAllPropertiesExcept(string ...$propertyNames)

Allow all properties during property mapping, but reject a few selected ones.

skipUnknownProperties()

When this is enabled, properties that are disallowed will be skipped instead of triggering an error during mapping.

bool
shouldSkipUnknownProperties()

Whether unknown (unconfigured) properties should be skipped during mapping, instead if causing an error.

getConfigurationFor(string $propertyName)

Returns the sub-configuration for the passed $propertyName. Must ALWAYS return a valid configuration object!

string
getTargetPropertyName(string $sourcePropertyName)

Maps the given $sourcePropertyName to a target property name.

mixed
getConfigurationValue(string $typeConverterClassName, string $key)

No description

setMapping(string $sourcePropertyName, string $targetPropertyName)

Define renaming from Source to Target property.

setTypeConverterOptions(string $typeConverter, array $options)

Set all options for the given $typeConverter.

setTypeConverterOption(string $typeConverter, int|string $optionKey, mixed $optionValue)

Set a single option (denoted by $optionKey) for the given $typeConverter.

array
getTypeConvertersWithParentClasses(string $typeConverter)

Get type converter classes including parents for the given type converter

forProperty(string $propertyPath)

Returns the configuration for the specific property path, ready to be modified. Should be used inside a fluent interface like: $configuration->forProperty('foo.bar')->setTypeConverterOption(....)

traverseProperties(array $splittedPropertyPath)

Traverse the property configuration. Only used by forProperty().

getTypeConverter()

Return the type converter set for this configuration.

setTypeConverter(TypeConverterInterface $typeConverter)

Set a type converter which should be used for this specific conversion.

allowCreationForSubProperty(string $propertyPath)

Allow creation of a certain sub property

allowModificationForSubProperty(string $propertyPath)

Allow modification for a given property path

allowOverrideTargetType()

Allow override of the target type through a special "__type" parameter

setTargetTypeForSubProperty(string $propertyPath, string $targetType)

Set the target type for a certain property. Especially useful if there is an object which has a nested object which is abstract, and you want to instantiate a concrete object instead.

Details

__construct()

No description

bool shouldMap(string $propertyName)

The behavior is as follows:

  • if a property has been explicitly forbidden using allowAllPropertiesExcept(...), it is directly rejected
  • if a property has been allowed using allowProperties(...), it is directly allowed.
  • if allowAllProperties* has been called, we allow unknown properties
  • else, return false.

Parameters

string $propertyName

Return Value

bool

true if the given propertyName should be mapped, false otherwise.

bool shouldSkip(string $propertyName)

Check if the given $propertyName should be skipped during mapping.

Parameters

string $propertyName

Return Value

bool

PropertyMappingConfiguration allowAllProperties()

Allow all properties in property mapping, even unknown ones.

Return Value

PropertyMappingConfiguration this

PropertyMappingConfiguration allowProperties(string ...$propertyNames)

Allow a list of specific properties. All arguments of allowProperties are used here (varargs).

Example: allowProperties('title', 'content', 'author')

Parameters

string ...$propertyNames

Return Value

PropertyMappingConfiguration this

PropertyMappingConfiguration skipProperties(string ...$propertyNames)

Skip a list of specific properties. All arguments of skipProperties are used here (varargs).

Example: skipProperties('unused', 'dummy')

Parameters

string ...$propertyNames

Return Value

PropertyMappingConfiguration this

PropertyMappingConfiguration allowAllPropertiesExcept(string ...$propertyNames)

Allow all properties during property mapping, but reject a few selected ones.

Example: allowAllPropertiesExcept('password', 'userGroup')

Parameters

string ...$propertyNames

Return Value

PropertyMappingConfiguration this

PropertyMappingConfiguration skipUnknownProperties()

When this is enabled, properties that are disallowed will be skipped instead of triggering an error during mapping.

Return Value

PropertyMappingConfiguration this

bool shouldSkipUnknownProperties()

Whether unknown (unconfigured) properties should be skipped during mapping, instead if causing an error.

Return Value

bool

PropertyMappingConfigurationInterface getConfigurationFor(string $propertyName)

Returns the sub-configuration for the passed $propertyName. Must ALWAYS return a valid configuration object!

Parameters

string $propertyName

Return Value

PropertyMappingConfigurationInterface

the property mapping configuration for the given $propertyName.

string getTargetPropertyName(string $sourcePropertyName)

Maps the given $sourcePropertyName to a target property name.

Parameters

string $sourcePropertyName

Return Value

string

property name of target

mixed getConfigurationValue(string $typeConverterClassName, string $key)

No description

Parameters

string $typeConverterClassName
string $key

Return Value

mixed

configuration value for the specific $typeConverterClassName. Can be used by Type Converters to fetch converter-specific configuration

PropertyMappingConfiguration setMapping(string $sourcePropertyName, string $targetPropertyName)

Define renaming from Source to Target property.

Parameters

string $sourcePropertyName
string $targetPropertyName

Return Value

PropertyMappingConfiguration this

PropertyMappingConfiguration setTypeConverterOptions(string $typeConverter, array $options)

Set all options for the given $typeConverter.

Parameters

string $typeConverter

class name of type converter

array $options

Return Value

PropertyMappingConfiguration this

PropertyMappingConfiguration setTypeConverterOption(string $typeConverter, int|string $optionKey, mixed $optionValue)

Set a single option (denoted by $optionKey) for the given $typeConverter.

Parameters

string $typeConverter

class name of type converter

int|string $optionKey
mixed $optionValue

Return Value

PropertyMappingConfiguration this

protected array getTypeConvertersWithParentClasses(string $typeConverter)

Get type converter classes including parents for the given type converter

When setting an option on a subclassed type converter, this option must also be set on all its parent type converters.

Parameters

string $typeConverter

The type converter class

Return Value

array

Class names of type converters

PropertyMappingConfiguration forProperty(string $propertyPath)

Returns the configuration for the specific property path, ready to be modified. Should be used inside a fluent interface like: $configuration->forProperty('foo.bar')->setTypeConverterOption(....)

Parameters

string $propertyPath

Return Value

PropertyMappingConfiguration

(or a subclass thereof)

PropertyMappingConfiguration traverseProperties(array $splittedPropertyPath)

Traverse the property configuration. Only used by forProperty().

Parameters

array $splittedPropertyPath

Return Value

PropertyMappingConfiguration

(or a subclass thereof)

TypeConverterInterface|null getTypeConverter()

Return the type converter set for this configuration.

Return Value

TypeConverterInterface|null

The type converter to be used for this particular PropertyMappingConfiguration, or NULL if the system-wide configured type converter should be used.

PropertyMappingConfiguration setTypeConverter(TypeConverterInterface $typeConverter)

Set a type converter which should be used for this specific conversion.

Parameters

TypeConverterInterface $typeConverter

Return Value

PropertyMappingConfiguration this

MvcPropertyMappingConfiguration allowCreationForSubProperty(string $propertyPath)

Allow creation of a certain sub property

Parameters

string $propertyPath

Return Value

MvcPropertyMappingConfiguration this

MvcPropertyMappingConfiguration allowModificationForSubProperty(string $propertyPath)

Allow modification for a given property path

Parameters

string $propertyPath

Return Value

MvcPropertyMappingConfiguration this

MvcPropertyMappingConfiguration allowOverrideTargetType()

Allow override of the target type through a special "__type" parameter

MvcPropertyMappingConfiguration setTargetTypeForSubProperty(string $propertyPath, string $targetType)

Set the target type for a certain property. Especially useful if there is an object which has a nested object which is abstract, and you want to instantiate a concrete object instead.

Parameters

string $propertyPath
string $targetType

Return Value

MvcPropertyMappingConfiguration this