PropertyMappingConfiguration implements PropertyMappingConfigurationInterface
Concrete configuration object for the PropertyMapper.
Table of Contents
Interfaces
- PropertyMappingConfigurationInterface
- Configuration object for the property mapper.
Constants
- PROPERTY_PATH_PLACEHOLDER = '*'
- Placeholder in property paths for multi-valued types
Properties
- $configuration : array<string|int, mixed>
- 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<string|int, mixed>
- Keys which should be renamed
- $mapUnknownProperties : bool
- If TRUE, unknown properties will be mapped.
- $propertiesNotToBeMapped : array<string|int, mixed>
- List of disallowed property names which will be ignored while property mapping
- $propertiesToBeMapped : array<string|int, mixed>
- List of allowed property names to be converted
- $propertiesToSkip : array<string|int, mixed>
- 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, PropertyMappingConfigurationInterface>
- Stores the configuration for specific child properties.
- $typeConverter : TypeConverterInterface
Methods
- allowAllProperties() : PropertyMappingConfiguration
- Allow all properties in property mapping, even unknown ones.
- allowAllPropertiesExcept() : PropertyMappingConfiguration
- Allow all properties during property mapping, but reject a few selected ones (blacklist).
- allowProperties() : PropertyMappingConfiguration
- Allow a list of specific properties. All arguments of allowProperties are used here (varargs).
- forProperty() : PropertyMappingConfiguration
- 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() : string
- Maps the given $sourcePropertyName to a target property name.
- getTypeConverter() : TypeConverterInterface|null
- Return the type converter set for this configuration.
- setMapping() : PropertyMappingConfiguration
- Define renaming from Source to Target property.
- setTypeConverter() : PropertyMappingConfiguration
- Set a type converter which should be used for this specific conversion.
- setTypeConverterOption() : PropertyMappingConfiguration
- Set a single option (denoted by $optionKey) for the given $typeConverter.
- setTypeConverterOptions() : PropertyMappingConfiguration
- 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 (unconfigured) properties should be skipped during mapping, instead if causing an error.
- skipProperties() : PropertyMappingConfiguration
- Skip a list of specific properties. All arguments of skipProperties are used here (varargs).
- skipUnknownProperties() : PropertyMappingConfiguration
- When this is enabled, properties that are disallowed will be skipped instead of triggering an error during mapping.
- traverseProperties() : PropertyMappingConfiguration
- Traverse the property configuration. Only used by forProperty().
- getTypeConvertersWithParentClasses() : array<string|int, mixed>
- 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<string|int, mixed>
$configuration
$mapping
Keys which should be renamed
protected
array<string|int, mixed>
$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<string|int, mixed>
$propertiesNotToBeMapped
= []
$propertiesToBeMapped
List of allowed property names to be converted
protected
array<string|int, mixed>
$propertiesToBeMapped
= []
$propertiesToSkip
List of property names to be skipped during property mapping
protected
array<string|int, mixed>
$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, PropertyMappingConfigurationInterface>
$subConfigurationForProperty
= []
$typeConverter
protected
TypeConverterInterface
$typeConverter
Methods
allowAllProperties()
Allow all properties in property mapping, even unknown ones.
public
allowAllProperties() : PropertyMappingConfiguration
Return values
PropertyMappingConfiguration —this
allowAllPropertiesExcept()
Allow all properties during property mapping, but reject a few selected ones (blacklist).
public
allowAllPropertiesExcept() : PropertyMappingConfiguration
Example: allowAllPropertiesExcept('password', 'userGroup')
Return values
PropertyMappingConfiguration —this
allowProperties()
Allow a list of specific properties. All arguments of allowProperties are used here (varargs).
public
allowProperties() : PropertyMappingConfiguration
Example: allowProperties('title', 'content', 'author')
Return values
PropertyMappingConfigurationforProperty()
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(....)
public
forProperty(string $propertyPath) : PropertyMappingConfiguration
Parameters
- $propertyPath : string
Return values
PropertyMappingConfiguration —(or a subclass thereof)
getConfigurationFor()
Returns the sub-configuration for the passed $propertyName. Must ALWAYS return a valid configuration object!
public
getConfigurationFor(string $propertyName) : PropertyMappingConfigurationInterface
Parameters
- $propertyName : string
Return values
PropertyMappingConfigurationInterface —the property mapping configuration for the given $propertyName.
getConfigurationValue()
public
getConfigurationValue(string $typeConverterClassName, string $key) : mixed
Parameters
- $typeConverterClassName : string
- $key : string
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(string $sourcePropertyName) : string
Parameters
- $sourcePropertyName : string
Return values
string —property name of target
getTypeConverter()
Return the type converter set for this configuration.
public
getTypeConverter() : TypeConverterInterface|null
Return values
TypeConverterInterface|nullsetMapping()
Define renaming from Source to Target property.
public
setMapping(string $sourcePropertyName, string $targetPropertyName) : PropertyMappingConfiguration
Parameters
- $sourcePropertyName : string
- $targetPropertyName : string
Return values
PropertyMappingConfiguration —this
setTypeConverter()
Set a type converter which should be used for this specific conversion.
public
setTypeConverter(TypeConverterInterface $typeConverter) : PropertyMappingConfiguration
Parameters
- $typeConverter : TypeConverterInterface
Return values
PropertyMappingConfiguration —this
setTypeConverterOption()
Set a single option (denoted by $optionKey) for the given $typeConverter.
public
setTypeConverterOption(string $typeConverter, string $optionKey, mixed $optionValue) : PropertyMappingConfiguration
Parameters
- $typeConverter : string
-
class name of type converter
- $optionKey : string
- $optionValue : mixed
Return values
PropertyMappingConfiguration —this
setTypeConverterOptions()
Set all options for the given $typeConverter.
public
setTypeConverterOptions(string $typeConverter, array<string|int, mixed> $options) : PropertyMappingConfiguration
Parameters
- $typeConverter : string
-
class name of type converter
- $options : array<string|int, mixed>
Return values
PropertyMappingConfiguration —this
shouldMap()
The behavior is as follows:
public
shouldMap(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 : 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(string $propertyName) : bool
Parameters
- $propertyName : string
Return values
boolshouldSkipUnknownProperties()
Whether unknown (unconfigured) properties should be skipped during mapping, instead if causing an error.
public
shouldSkipUnknownProperties() : bool
Return values
boolskipProperties()
Skip a list of specific properties. All arguments of skipProperties are used here (varargs).
public
skipProperties() : PropertyMappingConfiguration
Example: skipProperties('unused', 'dummy')
Return values
PropertyMappingConfiguration —this
skipUnknownProperties()
When this is enabled, properties that are disallowed will be skipped instead of triggering an error during mapping.
public
skipUnknownProperties() : PropertyMappingConfiguration
Return values
PropertyMappingConfiguration —this
traverseProperties()
Traverse the property configuration. Only used by forProperty().
public
traverseProperties(array<string|int, mixed> $splittedPropertyPath) : PropertyMappingConfiguration
Parameters
- $splittedPropertyPath : array<string|int, mixed>
Return values
PropertyMappingConfiguration —(or a subclass thereof)
getTypeConvertersWithParentClasses()
Get type converter classes including parents for the given type converter
protected
getTypeConvertersWithParentClasses(string $typeConverter) : array<string|int, mixed>
When setting an option on a subclassed type converter, this option must also be set on all its parent type converters.
Parameters
- $typeConverter : string
-
The type converter class
Return values
array<string|int, mixed> —Class names of type converters