Dispatches a CleverAge\ProcessBundle\Event\EventDispatcherTaskEvent through the Symfony event dispatcher. The event
gives listeners access to the current ProcessState (getState()), so they can read the input and, when the task is
not passive, set the output themselves.
- Service:
CleverAge\ProcessBundle\Task\Event\EventDispatcherTask - Code:
event_dispatcher(task: event_dispatcher)
any
any: the input, unchanged, whenpassiveistrue- when
passiveisfalse: whatever a listener set with$event->getState()->setOutput(),nullotherwise
| Code | Type | Required | Default | Description |
|---|---|---|---|---|
event_name |
string|null |
null |
Name of the dispatched event, null to use the event class name (see Notes) |
|
passive |
bool |
true |
If true, the input is passed to the output before dispatch |
- Dispatch an event for each item
# Task configuration level
data:
task: constant_iterable_output
options:
output: [1, 2, 3]
outputs: [push_data_event]
push_data_event:
task: event_dispatcher
options:
event_name: myapp.data_queueThe event is dispatched with $eventDispatcher->dispatch($event, $eventName):
- when
event_nameis set, listeners must subscribe to that name:
#[AsEventListener(event: 'myapp.data_queue')]
public function onDataQueue(EventDispatcherTaskEvent $event): void
{
$input = $event->getState()->getInput();
}- when
event_nameisnull, the event name is the event class name, so listeners must subscribe toCleverAge\ProcessBundle\Event\EventDispatcherTaskEvent. EveryEventDispatcherTaskwithoutevent_namethen triggers the same listeners.
Since v6.0, an event dispatched under its event_name is no longer dispatched under its class name too: the listeners
of CleverAge\ProcessBundle\Event\EventDispatcherTaskEvent are only called by the tasks without event_name. From
v4.0 to v5.x, they were also called (deprecated since 5.1) when event_name was set: listen to the configured
event_name instead, or remove the event_name option.