You are browsing a version that is no longer maintained. |
Entity Listeners
Entity listeners that are services must be registered with the entity listener resolver. You can tag your entity listeners and they will automatically be added to the resolver. Use the entity_manager attribute to specify which entity manager it should be registered with. Example:
- YAML
- XML
1 <?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <services> <service id="user_listener" class="UserListener"> <tag name="doctrine.orm.entity_listener" /> <tag name="doctrine.orm.entity_listener" entity_manager="custom" /> </service> </services> </container> 2 3 4 5 6 7 8 9 10 11 12
If you use a version of doctrine/orm < 2.5 you have to register the entity listener in your entity as well:
See also http://doctrine-orm.readthedocs.org/en/latest/reference/events.html#entity-listeners for more info on entity listeners.