Apply a chain of transformers to each element of an iterable value. Keys are preserved.
- Service:
CleverAge\ProcessBundle\Transformer\Array\ArrayMapTransformer - Transformer code:
array_map
array or \Traversable. Any other value throws an \UnexpectedValueException.
array: the transformed elements, with their original keys
| Code | Type | Required | Default | Description |
|---|---|---|---|---|
transformers |
array |
X | Transformers applied to each element, see TransformerTrait | |
skip_null |
bool |
false |
If true, elements whose transformed value is null are removed from the result |
When a sub-transformer fails, the thrown TransformerException references the key of the failing element.
- Cast each element to string, then uppercase it
# Transformer mapping level
array_map:
code:
- '[id]'
- '[firstname]'
- '[lastname]'
transformers:
array_map:
transformers:
cast:
type: 'string'
callback:
callback: strtoupper- Convert each
stdClassitem into an array and remap it
# Transformer options level
array_map:
transformers:
cast:
type: 'array'
mapping:
mapping:
isoCode:
code: '[sISOCode]'
name:
code: '[sName]'