You are browsing a version that has not yet been released.

Event Listeners

In opposite to Entity Listeners, Event listeners are services that listen for all entities in your application.

See https://www.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html#implementing-event-listeners for more info on event listeners.

To register a service to act as an event listener you have to tag it with the doctrine.event_listener tag:

Starting with Doctrine bundle 2.8, you can use the AsDoctrineListener attribute to tag the service.

// src/App/EventListener/SearchIndexer.phpnamespace App\EventListener;use Doctrine\Bundle\DoctrineBundle\Attribute\AsDoctrineListener;use Doctrine\ORM\Event\LifecycleEventArgs;#[AsDoctrineListener('postPersist'/*, 500, 'default'*/)]class SearchIndexer{    public function postPersist(LifecycleEventArgs $event): void    {        // ...    }}