During the lifecycle of a job events are dispatched using the Symfony Event Dispatcher.
Before every execution of a job an event with the name abc.job.pre_execute is dispatched.
In order to register an event listener for this event you have to define the listener class, register it as a service and tag it:
# app/config/config.yml
services:
acme.listener.your_listener_name:
class: Acme\Bundle\MyBundle\Listener\MyJobListener
tags:
- { name: abc.job.event_listener, event: abc.job.pre_execute, method: onPreExecute }The dispatched event is of type ExecutionEvent which gives listeners the option to modify the job or to provide runtime parameters.
After every execution of a job an event with the name abc.job.post_execute is dispatched.
In order to register an event listener for this event you have to define the listener class, register it as a service and tag it:
# app/config/config.yml
services:
acme.listener.your_listener_name:
class: Acme\Bundle\MyBundle\Listener\MyJobListener
tags:
- { name: abc.job.event_listener, event: abc.job.post_execute, method: onPostExecute }Like the Pre Execution Event the dispatched event is of type ExecutionEvent.
Whenever a job terminates an event with the name abc.job.terminated and of type TerminationEvent is dispatched.
In order to register an event listener for this event you have to define the listener class, register it as a service and tag it:
# app/config/config.yml
services:
acme.listener.your_listener_name:
class: Acme\Bundle\MyBundle\Listener\MyJobListener
tags:
- { name: abc.job.event_listener, event: abc.job.terminated, method: onTerminate }Back to index