Call a PHP callable (function or static method) with the input value. The value is inserted between configurable left
and right parameters: callback(...left_parameters, $value, ...right_parameters).
- Service:
CleverAge\ProcessBundle\Transformer\CallbackTransformer - Transformer code:
callback
any: whatever the callback accepts.
any: the return value of the callback.
| Code | Type | Required | Default | Description |
|---|---|---|---|---|
callback |
string|array |
X | A valid PHP callable (e.g. strtoupper, ['App\MyClass', 'myStaticMethod']), checked with is_callable |
|
left_parameters |
array |
[] |
Parameters passed before the value | |
right_parameters |
array |
[] |
Parameters passed after the value | |
additional_parameters |
array |
[] |
Deprecated: use right_parameters instead. Only used when right_parameters is empty |
- Simple PHP function
# Transformer options level
callback:
callback: strtoupper- Function with extra parameters:
json_decode($value, true)
# Transformer options level
callback:
callback: json_decode
right_parameters: [true]- Value in second position:
explode(',', $value)
# Transformer options level
callback:
callback: explode
left_parameters: [',']