PropertyMappingConfiguration
class PropertyMappingConfiguration implements PropertyMappingConfigurationInterface (View source)
Concrete configuration object for the PropertyMapper.
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:
|
|
protected PropertyMappingConfigurationInterface[] | $subConfigurationForProperty | Stores the configuration for specific child properties. |
|
protected array | $mapping | Keys which should be renamed |
|
protected TypeConverterInterface | $typeConverter | ||
protected array | $propertiesToBeMapped | List of allowed property names to be converted |
|
protected array | $propertiesToSkip | List of property names to be skipped during property mapping |
|
protected array | $propertiesNotToBeMapped | List of disallowed property names which will be ignored while property mapping |
|
protected bool | $skipUnknownProperties | If true, unknown properties will be skipped during property mapping |
|
protected bool | $mapUnknownProperties | If true, unknown properties will be mapped. |
Methods
The behavior is as follows:
Check if the given $propertyName should be skipped during mapping.
Allow all properties in property mapping, even unknown ones.
Allow a list of specific properties. All arguments of allowProperties are used here (varargs).
Skip a list of specific properties. All arguments of skipProperties are used here (varargs).
Allow all properties during property mapping, but reject a few selected ones.
When this is enabled, properties that are disallowed will be skipped instead of triggering an error during mapping.
Whether unknown (unconfigured) properties should be skipped during mapping, instead if causing an error.
Returns the sub-configuration for the passed $propertyName. Must ALWAYS return a valid configuration object!
Maps the given $sourcePropertyName to a target property name.
No description
Define renaming from Source to Target property.
Set all options for the given $typeConverter.
Set a single option (denoted by $optionKey) for the given $typeConverter.
Get type converter classes including parents for the given type converter
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(....)
Traverse the property configuration. Only used by forProperty().
Return the type converter set for this configuration.
Set a type converter which should be used for this specific conversion.
Details
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.
bool
shouldSkip(string $propertyName)
Check if the given $propertyName should be skipped during mapping.
PropertyMappingConfiguration
allowAllProperties()
Allow all properties in property mapping, even unknown ones.
PropertyMappingConfiguration
allowProperties(string ...$propertyNames)
Allow a list of specific properties. All arguments of allowProperties are used here (varargs).
Example: allowProperties('title', 'content', 'author')
PropertyMappingConfiguration
skipProperties(string ...$propertyNames)
Skip a list of specific properties. All arguments of skipProperties are used here (varargs).
Example: skipProperties('unused', 'dummy')
PropertyMappingConfiguration
allowAllPropertiesExcept(string ...$propertyNames)
Allow all properties during property mapping, but reject a few selected ones.
Example: allowAllPropertiesExcept('password', 'userGroup')
PropertyMappingConfiguration
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.
PropertyMappingConfigurationInterface
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
PropertyMappingConfiguration
setMapping(string $sourcePropertyName, string $targetPropertyName)
Define renaming from Source to Target property.
PropertyMappingConfiguration
setTypeConverterOptions(string $typeConverter, array $options)
Set all options for the given $typeConverter.
PropertyMappingConfiguration
setTypeConverterOption(string $typeConverter, int|string $optionKey, mixed $optionValue)
Set a single option (denoted by $optionKey) for the given $typeConverter.
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.
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(....)
PropertyMappingConfiguration
traverseProperties(array $splittedPropertyPath)
Traverse the property configuration. Only used by forProperty().
TypeConverterInterface
getTypeConverter()
Return the type converter set for this configuration.
PropertyMappingConfiguration
setTypeConverter(TypeConverterInterface $typeConverter)
Set a type converter which should be used for this specific conversion.