Allow Entity Listener to match interface #6452

Open
opened 2026-01-22 15:33:30 +01:00 by admin · 6 comments
Owner

Originally created by @hermann8u on GitHub (Apr 21, 2020).

Feature Request

Q A
New Feature yes
RFC no
BC Break no

Summary

Hi,

There is a drawback using lifecycle listeners because they are called for every entities. On the other hand, entity listener can be applied only on one entity, limiting the number of calls, but not on interfaces.

Most of the time, when we use lifecycle listeners, the goal is to match an interface. That's why it will be great to have the possibility to use entity listeners mapped with an interface instead.

As a reference, here is a post on the same subject: https://dev.to/c33s/doctrine-simple-event-listener-are-not-interface-compatible-ioj

Originally created by @hermann8u on GitHub (Apr 21, 2020). ### Feature Request <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |------------ | ------ | New Feature | yes | RFC | no | BC Break | no #### Summary Hi, There is a drawback using lifecycle listeners because they are called for every entities. On the other hand, entity listener can be applied only on one entity, limiting the number of calls, but not on interfaces. Most of the time, when we use lifecycle listeners, the goal is to match an interface. That's why it will be great to have the possibility to use entity listeners mapped with an interface instead. As a reference, here is a post on the same subject: https://dev.to/c33s/doctrine-simple-event-listener-are-not-interface-compatible-ioj
Author
Owner

@greg0ire commented on GitHub (Apr 21, 2020):

Possible next step: find the PR that introduced that feature, and see if this has already been discussed.

@greg0ire commented on GitHub (Apr 21, 2020): Possible next step: find the PR that introduced that feature, and see if this has already been discussed.
Author
Owner

@hermann8u commented on GitHub (Apr 21, 2020):

Yeah I tried to find isues and PR discuting about this (maybe not enought?). It's difficult to find something in more than 1100 issues and 250 PR though :/

So I guess there is something in that direction? Can I close this one?

@hermann8u commented on GitHub (Apr 21, 2020): Yeah I tried to find isues and PR discuting about this (maybe not enought?). It's difficult to find something in more than 1100 issues and 250 PR though :/ So I guess there is something in that direction? Can I close this one?
Author
Owner

@greg0ire commented on GitHub (Apr 21, 2020):

So I guess there is something in that direction?

Uuuh no? Since you did not find anything

Can I close this one?

Well, no, why would you close it?

Yeah I tried to find isues and PR discuting about this (maybe not enought?). It's difficult to find something in more than 1100 issues and 250 PR though :/

It is, that's why you should use the git log instead. The first step would be to use git log -S EntityListenerOrWhateverThisIsCalled to find the first commit that introduces it.

@greg0ire commented on GitHub (Apr 21, 2020): > So I guess there is something in that direction? Uuuh no? Since you did not find anything > Can I close this one? Well, no, why would you close it? > Yeah I tried to find isues and PR discuting about this (maybe not enought?). It's difficult to find something in more than 1100 issues and 250 PR though :/ It is, that's why you should use the git log instead. The first step would be to use `git log -S EntityListenerOrWhateverThisIsCalled` to find the first commit that introduces it.
Author
Owner

@SimonVanacco commented on GitHub (Jan 5, 2023):

I think this would be a huge QoL improvement to EntityListeners, is there any way to help achieve this ?

@SimonVanacco commented on GitHub (Jan 5, 2023): I think this would be a huge QoL improvement to EntityListeners, is there any way to help achieve this ?
Author
Owner

@derrabus commented on GitHub (Jan 6, 2023):

is there any way to help achieve this ?

Create a PR that implements this feature.

@derrabus commented on GitHub (Jan 6, 2023): > is there any way to help achieve this ? Create a PR that implements this feature.
Author
Owner

@janklan commented on GitHub (Mar 23, 2023):

@SimonVanacco Implement a life cycle listener and ignore all events not related to the interface of your interest. That's what I did, anyway.

@janklan commented on GitHub (Mar 23, 2023): @SimonVanacco Implement a life cycle listener and ignore all events not related to the interface of your interest. That's what I did, anyway.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6452