Jira issue originally created by user c0ba:
According to http://www.doctrine-project.org/docs/orm/2.1/en/reference/events.html
Current event system seem to be not as flexible as it could be.
Here is the situation:
I have an entity for a news item. After somehow modifying this entity and before persisting I want to be able to change the inner association of images linked to this news (for example parsed from news body text). From the OO point of view it's a task of the News entity itself so this should be done a callback. But since inside callback I do not have access to entity manager (to find existing image entities and only if not found creating a new one) I cannot do this.
This leads to creating a separate event listener which is split from the news entity (and that is not possible, see 2.).
Passing entity manager to callbacks may improve it's usefulness.
Also I faced a problem when implementing the event listener for situation 1. If I register the onFlush listener - the entites changeset is already calculated. If I change something according associations I loose this changes.
If I call $unitOfWork->computeChangeSet($classMetadata, $entity) or $unitOfWork->recomputeSingleEntityChangeSet($classMetadata, $entity); I only get the changes being made after previous changeset calculation loosing the initial changes. I think the preFlush could be a lifesaver for this (to be called before computing the changeset for the first time).