Convert a value into another one using a conversion map (lookup table).
- Service:
CleverAge\ProcessBundle\Transformer\ConvertValueTransformer - Transformer code:
convert_value
stringorint: used as a key ofmapnull: always returnsnull, without lookup- other scalars or objects: only if
auto_castistrue(cast to string), otherwise anUnexpectedValueExceptionis thrown. Arrays are always rejected.
any: the value matching the input in map, the input itself (keep_missing) or null (ignore_missing).
| Code | Type | Required | Default | Description |
|---|---|---|---|---|
map |
array |
X | Conversion table: input value as key, output value as value | |
ignore_missing |
bool |
false |
If true, return null when the value is not in map, instead of throwing an UnexpectedValueException |
|
keep_missing |
bool |
false |
If true, return the input when the value is not in map (takes precedence on ignore_missing) |
|
auto_cast |
bool |
false |
If true, cast input values that are not valid array keys (float, bool, Stringable...) to string |
- Simple conversion, unknown values become
null
# Transformer options level
convert_value:
map:
TEXTE: text
NUMERIQUE: number
DATE: date
ignore_missing: true- Keep the original value when it is not in the map
# Transformer options level
convert_value:
map:
old_code: new_code
keep_missing: true