Remove a key from the input array, optionally only when a condition is met.
- Service:
CleverAge\ProcessBundle\Transformer\UnsetTransformer - Transformer code:
unset
array containing the property key. An UnexpectedValueException is thrown if the input is not an array (null
included), or if the key does not exist (even when the condition is not met).
array: the input, without the property key if the condition is met.
| Code | Type | Required | Default | Description |
|---|---|---|---|---|
property |
string |
X | Array key to remove (a plain key, not a property path) | |
condition |
array |
[] |
Conditions checked against the input before removing the key, see ConditionTrait. Always met when empty |
- Unconditionally remove a key
# Transformer options level
unset:
property: internal_id- Remove the key only if another value matches
# Transformer options level
unset:
property: debug_info
condition:
match:
'[environment]': production