MvcPropertyMappingConfiguration extends PropertyMappingConfiguration

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

Table of Contents

Constants

PROPERTY_PATH_PLACEHOLDER  = '*'
Placeholder in property paths for multi-valued types

Properties

$configuration  : array<TypeConverterInterface>, non-empty-string|int>
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
$mapping  : array<non-empty-string, non-empty-string>
Keys which should be renamed
$mapUnknownProperties  : bool
If TRUE, unknown properties will be mapped.
$propertiesNotToBeMapped  : array<non-empty-string, non-empty-string>
List of disallowed property names which will be ignored while property mapping
$propertiesToBeMapped  : array<non-empty-string, non-empty-string>
List of allowed property names to be converted
$propertiesToSkip  : array<non-empty-string, non-empty-string>
List of property names to be skipped during property mapping
$skipUnknownProperties  : bool
If TRUE, unknown properties will be skipped during property mapping
$subConfigurationForProperty  : array<string|int, mixed>
Stores the configuration for specific child properties.
$typeConverter  : TypeConverterInterface|null

Methods

allowAllProperties()  : $this
Allow all properties in property mapping, even unknown ones.
allowAllPropertiesExcept()  : $this
Allow all properties during property mapping, but reject a few selected ones (blacklist).
allowCreationForSubProperty()  : mixed
Allow creation of a certain sub property
allowModificationForSubProperty()  : mixed
Allow modification for a given property path
allowProperties()  : $this
Allow a list of specific properties. All arguments of allowProperties are used here (varargs).
forProperty()  : PropertyMappingConfigurationInterface
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(....)
getConfigurationFor()  : PropertyMappingConfigurationInterface
Returns the sub-configuration for the passed $propertyName. Must ALWAYS return a valid configuration object!
getConfigurationValue()  : mixed
getTargetPropertyName()  : non-empty-string
Maps the given $sourcePropertyName to a target property name.
getTypeConverter()  : TypeConverterInterface|null
Return the type converter set for this configuration.
setMapping()  : $this
Define renaming from Source to Target property.
setTargetTypeForSubProperty()  : mixed
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.
setTypeConverter()  : $this
Set a type converter which should be used for this specific conversion.
setTypeConverterOption()  : $this
Set a single option (denoted by $optionKey) for the given $typeConverter.
setTypeConverterOptions()  : $this
Set all options for the given $typeConverter.
shouldMap()  : bool
The behavior is as follows:
shouldSkip()  : bool
Check if the given $propertyName should be skipped during mapping.
shouldSkipUnknownProperties()  : bool
Whether unknown (non configured) properties should be skipped during mapping, instead if causing an error.
skipProperties()  : $this
Skip a list of specific properties. All arguments of skipProperties are used here (varargs).
skipUnknownProperties()  : $this
When this is enabled, properties that are disallowed will be skipped instead of triggering an error during mapping.
traverseProperties()  : PropertyMappingConfigurationInterface
Traverse the property configuration. Only used by forProperty().
getTypeConvertersWithParentClasses()  : array<string|int, class-string>
Get type converter classes including parents for the given type converter

Constants

PROPERTY_PATH_PLACEHOLDER

Placeholder in property paths for multi-valued types

public mixed PROPERTY_PATH_PLACEHOLDER = '*'

Properties

$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

protected array<TypeConverterInterface>, non-empty-string|int> $configuration = []

$mapping

Keys which should be renamed

protected array<non-empty-string, non-empty-string> $mapping = []

$mapUnknownProperties

If TRUE, unknown properties will be mapped.

protected bool $mapUnknownProperties = false

$propertiesNotToBeMapped

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

protected array<non-empty-string, non-empty-string> $propertiesNotToBeMapped = []

$propertiesToBeMapped

List of allowed property names to be converted

protected array<non-empty-string, non-empty-string> $propertiesToBeMapped = []

$propertiesToSkip

List of property names to be skipped during property mapping

protected array<non-empty-string, non-empty-string> $propertiesToSkip = []

$skipUnknownProperties

If TRUE, unknown properties will be skipped during property mapping

protected bool $skipUnknownProperties = false

$subConfigurationForProperty

Stores the configuration for specific child properties.

protected array<string|int, mixed> $subConfigurationForProperty = []

Methods

allowAllProperties()

Allow all properties in property mapping, even unknown ones.

public allowAllProperties() : $this
Return values
$this

allowAllPropertiesExcept()

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

public allowAllPropertiesExcept(non-empty-string ...$propertyNames) : $this

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

Parameters
$propertyNames : non-empty-string
Return values
$this

allowCreationForSubProperty()

Allow creation of a certain sub property

public allowCreationForSubProperty(string $propertyPath) : mixed
Parameters
$propertyPath : string

allowModificationForSubProperty()

Allow modification for a given property path

public allowModificationForSubProperty(string $propertyPath) : mixed
Parameters
$propertyPath : string

allowProperties()

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

public allowProperties(non-empty-string ...$propertyNames) : $this

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

Parameters
$propertyNames : non-empty-string
Return values
$this

getConfigurationValue()

public getConfigurationValue(TypeConverterInterface> $typeConverterClassName, non-empty-string|int $key) : mixed
Parameters
$typeConverterClassName : TypeConverterInterface>
$key : non-empty-string|int
Return values
mixed

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

getTargetPropertyName()

Maps the given $sourcePropertyName to a target property name.

public getTargetPropertyName(non-empty-string $sourcePropertyName) : non-empty-string
Parameters
$sourcePropertyName : non-empty-string
Return values
non-empty-string

property name of target

getTypeConverter()

Return the type converter set for this configuration.

public getTypeConverter() : TypeConverterInterface|null
Return values
TypeConverterInterface|null

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

setMapping()

Define renaming from Source to Target property.

public setMapping(non-empty-string $sourcePropertyName, non-empty-string $targetPropertyName) : $this
Parameters
$sourcePropertyName : non-empty-string
$targetPropertyName : non-empty-string
Return values
$this

setTargetTypeForSubProperty()

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.

public setTargetTypeForSubProperty(string $propertyPath, string $targetType) : mixed
Parameters
$propertyPath : string
$targetType : string

setTypeConverterOption()

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

public setTypeConverterOption(TypeConverterInterface> $typeConverter, non-empty-string|int $optionKey, mixed $optionValue) : $this
Parameters
$typeConverter : TypeConverterInterface>

class name of type converter

$optionKey : non-empty-string|int
$optionValue : mixed
Return values
$this

setTypeConverterOptions()

Set all options for the given $typeConverter.

public setTypeConverterOptions(TypeConverterInterface> $typeConverter, array<string|int, mixed> $options) : $this
Parameters
$typeConverter : TypeConverterInterface>

class name of type converter

$options : array<string|int, mixed>
Return values
$this

shouldMap()

The behavior is as follows:

public shouldMap(non-empty-string $propertyName) : bool
  • 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
$propertyName : non-empty-string
Return values
bool

TRUE if the given propertyName should be mapped, FALSE otherwise.

shouldSkip()

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

public shouldSkip(non-empty-string $propertyName) : bool
Parameters
$propertyName : non-empty-string
Return values
bool

shouldSkipUnknownProperties()

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

public shouldSkipUnknownProperties() : bool
Return values
bool

skipProperties()

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

public skipProperties(non-empty-string ...$propertyNames) : $this

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

Parameters
$propertyNames : non-empty-string
Return values
$this

skipUnknownProperties()

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

public skipUnknownProperties() : $this
Return values
$this

getTypeConvertersWithParentClasses()

Get type converter classes including parents for the given type converter

protected getTypeConvertersWithParentClasses(TypeConverterInterface> $typeConverter) : array<string|int, class-string>

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

Parameters
$typeConverter : TypeConverterInterface>

The type converter class

Return values
array<string|int, class-string>

Class names of type converters


        
On this page

Search results