You are browsing a version that is no longer maintained. |
Doctrine PHPCR-ODM Events
Doctrine PHPCR-ODM provides an event system allowing to react to all important operations that documents have during their lifecycle. Please see the Doctrine PHPCR-ODM event system documentation for a full list of supported events.
The DoctrinePHPCRBundle provides dependency injection support for the event listeners and event subscribers.
Dependency Injection Tags
You can tag services to listen to Doctrine PHPCR-ODM events. It works the same way as for Doctrine ORM events. The only differences are:
- use the tag name
doctrine_phpcr.event_listener
resp.doctrine_phpcr.event_subscriber
instead ofdoctrine.event_listener
; - expect the argument to be of class
Doctrine\Common\Persistence\Event\LifecycleEventArgs
.
To tag a service as event listener and another service as event subscriber, use this configuration:
Doctrine event subscribers (both ORM and PHPCR-ODM) can not return a flexible array of methods to call like the Symfony event subscriber. Doctrine event subscribers must return a simple array of the event names they subscribe to. Doctrine will then expect methods on the subscriber with the names of the subscribed events, just as when using an event listener. |
You can find more information and examples of the doctrine event system in "How to Register Event Listeners and Subscribers" of the core documentation.