-
Notifications
You must be signed in to change notification settings - Fork 519
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
Use entity listeners instead of event listeners #619
Comments
relates to #617 |
Dear community, I need suggestion about implementing this feature. The problem is: we need get all mapped classes/properties inside compiler pass for creating listeners for each mapping. How it possible to do? I see 2 variants: a. get some magic metadata reader service inside compiler pass like in propel compiler pass and read all metadatas for all classes your suggestions? |
Option |
Oher problem caused by option Maybe something like this https://abendstille.at/blog/?p=163 but it will slow down container recompilation. But we win in production. |
I see 2 issues with options A:
I suggest you to go with option b (which may even allow to make the configuration working the same for all persistence layers btw). |
Btw, another option to improve performance is to register a single Doctrine event listener rather than multiple ones. This should be investigated too. |
If we move mappings configuration to
Did you mean single entity listener (which attached to concrete entity) or just single event listener (attached to all entities)? |
no, I meant a single event listener, which will then know how to handle all uploadable entities (instead of having one global listener per entity). This may allow to keep using a single listener while keeping the existing configuration way. Note that entity listeners are still using an event listener internally (a single one registered by the ORM, and filtering which entity listeners to call based on the entity being affected by the event). |
why not using an event listener for the ORM too ? It may even allow to use the same listener implementation for all Doctrine projects (though registering different instances for each o*m) |
ok, will move in this direction |
As I understand correctly - we create for each mupping N listeners. And all of this listeners called each time when any entity changes (even if it not mapped). Starting from Doctrine 2.4 there is entity listeners http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html#entity-listeners which associated only with entity.
We can improve performance a lot by:
isUploadable
andgetUploadableFields
inside listeners because we already know which fields are uploadable for this listenerThe text was updated successfully, but these errors were encountered: