DDC-1980: [GH-423] DDC-1955 - @EntityListeners #2500

Closed
opened 2026-01-22 13:55:16 +01:00 by admin · 3 comments
Owner

Originally created by @doctrinebot on GitHub (Aug 12, 2012).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user @beberlei:

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
/****
 * @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
    }
}
Originally created by @doctrinebot on GitHub (Aug 12, 2012). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user @beberlei: 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](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 } } ```
admin added the New Feature label 2026-01-22 13:55:16 +01:00
admin closed this issue 2026-01-22 13:55:17 +01:00
Author
Owner

@doctrinebot commented on GitHub (Feb 27, 2013):

Comment created by @FabioBatSilva:

Merged : 71a68a5c6f

@doctrinebot commented on GitHub (Feb 27, 2013): Comment created by @FabioBatSilva: Merged : https://github.com/doctrine/doctrine2/commit/71a68a5c6fcd49538c3ef2f86d64bcde1958251c
Author
Owner

@doctrinebot commented on GitHub (Feb 27, 2013):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Feb 27, 2013): Issue was closed with resolution "Fixed"
Author
Owner

@doctrinebot commented on GitHub (Dec 18, 2013):

Comment created by @doctrinebot:

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

@doctrinebot commented on GitHub (Dec 18, 2013): Comment created by @doctrinebot: A related Github Pull-Request [GH-423] was closed: https://github.com/doctrine/dbal/pull/423
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#2500