Read a value from the input using the Symfony PropertyAccessor and return it.
- Service:
CleverAge\ProcessBundle\Transformer\Object\PropertyAccessorTransformer - Transformer code:
property_accessor
array or object readable by the PropertyAccessor. null is accepted only when ignore_null is true.
any: the value found at the property pathnullif the input isnullandignore_nullistrue, or if the path is not readable andignore_missingistrue
| Code | Type | Required | Default | Description |
|---|---|---|---|---|
property_path |
string |
X | Property path to read (e.g. [key] for arrays, property for objects, [a][b], a.b) |
|
ignore_null |
bool |
false |
If true, return null when the input is null instead of failing |
|
ignore_missing |
bool |
false |
If true, return null when the property path is not readable instead of failing |
- Read a nested property of an object
# Transformer options level
property_accessor:
property_path: 'FullCountryInfoAllCountriesResult.tCountryInfo'- Read the 3rd element of a
preg_matchresult
# Transformer mapping level
third_element:
code: '[text]'
transformers:
preg_match:
pattern: '/(foo)(bar)(baz)/'
property_accessor:
property_path: '[2]'- Read an optional nested array key
# Transformer options level
property_accessor:
property_path: '[address][city]'
ignore_missing: true