MvcPropertyMappingConfiguration
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:
|
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
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.
Allow creation of a certain sub property
Allow modification for a given property path
Allow override of the target type through a special "__type" parameter
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.
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|null
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.
MvcPropertyMappingConfiguration
allowCreationForSubProperty(string $propertyPath)
Allow creation of a certain sub property
MvcPropertyMappingConfiguration
allowModificationForSubProperty(string $propertyPath)
Allow modification for a given property path
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.