Skip to content

Latest commit

 

History

History
56 lines (39 loc) · 2.04 KB

File metadata and controls

56 lines (39 loc) · 2.04 KB

Lifecycle Events

During the lifecycle of a job events are dispatched using the Symfony Event Dispatcher.

Pre Execute Event

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.

Post Execute Event

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.

Terminate Event

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