Skip to content
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

WIP Allow usage of Symfony EventDispatcher instead of Doctrine EventManager #2686

Draft
wants to merge 6 commits into
base: 2.10.x
Choose a base branch
from

Conversation

GromNaN
Copy link
Member

@GromNaN GromNaN commented Oct 9, 2024

Q A
Type feature
BC Break no
Fixed issues -

Summary

Symfony EventDispatcher is a very close to Doctrine EventManager in features (add/remove listener, and dispatch an event using a name and an event object).

Why not using sticking to PSR-14: Event Dispatcher?

The PSR EventDispatcher interface method dispatch(object $event) relies on the object class. But in Doctrine ODM, the same event class LifecycleEventArgs is used for multiple events (postUpdate, postRemove, postUpdate, prePersist, preRemove, preUpdate).
We can decide to create a distinct class for each event and use the PSR EventDispatcherInterface. With a map of class names to event names.

The event names are very generic, it would be possible to prefix them with doctrine.mongodb. to prevent any conflict if the same event dispatcher is used for other events outside of Doctrine.

Livecycle callbacks

The livecycle callbacks are not using the event manager, they are called independently in LifecycleEventManager.

@GromNaN GromNaN force-pushed the remove-event-manager branch from f456ca3 to c9b5a43 Compare October 9, 2024 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant