-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DoctrineBridge] Invokable event listeners #32486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DoctrineBridge] Invokable event listeners #32486
Conversation
3b699dd
to
c15a599
Compare
Invokable entity listeners will definitely be in DoctrineBundle 1.12, so I'm all for merging this PR for consistency 👍 |
1d55b2b
to
61fab3e
Compare
61fab3e
to
d6fd201
Compare
doctrine/DoctrineBundle#989 has been merged - what's the status here? |
I guess a review / approval would help 😄 |
|
The idea was to support it in both kinds of listeners for consistency. Entity listeners are tracked in DoctrineBundle while this PR covers global Doctrine listeners. |
I'm talking with @fancyweb on Slack, getting better insight here :) I don't think this is really a good idea, as using On the performance side also, please consider my argument: But that's only my first reaction, take it as a maybe hint or ignore it :) |
d6fd201
to
58f98ce
Compare
I just changed the implementation to not use SplObjectStorage anymore. get_class cannot be used because the same listener class can technically be used by 2 different events (one with the "__invoke" method and the other with the "eventName" method) ( But let's allow __invoke! It will be coherent with the DoctrineBundle + coherent with the Symfony event dispatcher component. __invoke will only be a fallback, you don't have to use it. We are not trying to force a new way to do things.
It depends your code structure. If your listener is in a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that removes my technical objection. I feel like my other objections aren't strong enough to refuse this PR, because we did it already elsewhere. So good to go for me, thanks.
572d007
to
55d0142
Compare
I detected a fail in my implementation and had to rework it. The $methods array have now a depth of 2 to store the methods by event and by hash. |
small rebase needed |
55d0142
to
47e872a
Compare
Thank you @fancyweb. |
This PR was merged into the 4.4 branch. Discussion ---------- [DoctrineBridge] Invokable event listeners | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | symfony/symfony-docs#11992 Invokable Doctrine entity listeners will likely be supported in the next version of the DoctrineBundle (cf doctrine/DoctrineBundle#989). I think it would also be great to support it for Doctrine event listeners. Commits ------- 47e872a [DoctrineBridge] Allow invokable event listeners
This PR was merged into the 4.4 branch. Discussion ---------- [Doctrine] Invokable event listeners Doc for symfony/symfony#32486 Commits ------- 736d96c [Doctrine] Invokable event listeners
Invokable Doctrine entity listeners will likely be supported in the next version of the DoctrineBundle (cf doctrine/DoctrineBundle#989).
I think it would also be great to support it for Doctrine event listeners.