[DDC-1980] [GH-423] DDC-1955 - @EntityListeners Created: 12/Aug/12  Updated: 18/Dec/13  Resolved: 27/Feb/13

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: 2.4
Security Level: All

Type: New Feature Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of FabioBatSilva:

Url: https://github.com/doctrine/doctrine2/pull/423

Message:

http://www.doctrine-project.org/jira/browse/DDC-1955

Hi.

This path adds support for ```@EntityListeners```

This path add another way to handle events
allow configure the same listener for many specific entities.
And give the EventArg in the current lifecycle callback system.

Usage :

```php
<?php
/**

  • @EntityListeners( {"ContractListener"}

    )

  • @HasLifecycleCallbacks
  • @Entity
    */
    class Contract
    {
    /** @PostLoad */
    public function postLoadHandler(LifecycleEventArgs $event) { // do something }
    }
    class ContractListener
    {
    /** @PrePersist */
    public function prePersistHandler(Contract $contract)
    { // do something }

    /**

  • @PostPersist
  • Most of cases just the entity is needed.
  • as a second parameter LifecycleEventArgs allow access to the entity manager.
    */
    public function postPersistHandler(Contract $contract, LifecycleEventArgs $args) { // do something }

    }
    ```



 Comments   
Comment by Fabio B. Silva [ 27/Feb/13 ]

Merged : https://github.com/doctrine/doctrine2/commit/71a68a5c6fcd49538c3ef2f86d64bcde1958251c

Comment by Doctrine Bot [ 18/Dec/13 ]

A related Github Pull-Request [GH-423] was closed:
https://github.com/doctrine/dbal/pull/423

Generated at Wed Nov 26 05:39:51 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.