Jira issue originally created by user Tadej:
I'm not sure if it's me, but I couldn't get "preRemove" callback/event working when "remove" action is triggered from related entity, but it works where the entity itself (the one with "preRemove" event) is removed directly.
According to documentation:
"If an association is marked as CASCADE=REMOVE Doctrine 2 will fetch this association. If its a Single association it will pass this entity to ´EntityManager#remove()`"....and similar for multiple entities.
"preRemove event is called on every entity when its passed to the EntityManager#remove()"
So according to documentation "preRemove" should get triggered on "cascade remove", but it doesn't get in my case. Is this normal behavior or a bug?
I'm not sure if it the problem might be in any of ZF2 modules, but I've decided to post the issue here, since I'm referring to documentation of this project.
Beside that I've also noticed that "orphan removal" doesn't work on ManyToMany, although documentation says that it's supported (on IRC they've said that it may be a bug in documentation, that it is not really yet supported...they found no code changes when documentation was changed).
Comment created by backbone:
Orphan removal can not be supported for Many-To-Many relations, because the feature makes the assumption that the related entity is "privately owned" by the entity defining the orphan removal feature. In a Many-To-Many relation a related entity can be related to multiple entities and therefore is not privately owned by the relation defining entity.