Reputation: 1565
I'm trying to persist a History
entity whenever a Message
gets updated. I have too much going on behind the scenes to post all the code here and for it to make sense, but I've basically tracked the issue down to the UnitOfWork::commit
method. There, the UOW first loops through the entityInsertions
, and finding nothing, continues on to the entityUpdates
. There the UOW's entityInsertions
gets updated, but since it's already past that loop, it doesn't pick up that it still needs to persist some entities. Is there any way to force the UOW to "restart" this process? If so, how? I'm using Doctrine 2.4.
Thanks for any help!
Upvotes: 0
Views: 742
Reputation: 1565
This might be the dirtiest solution ever, but what I ended up doing was basically the following...
onFlush
event subscriberUnitOfWork
's scheduledEntityUpdates
and scheduledEntityInserts
(I wasn't interested in deletes)LoggableInterface
, just to know which entities are loggable)LoggableInterface
objects in different ways)Persist the entity (the actual history event) via the entity manager, and do the following:
$classMeta = $this->entityManager->getClassMetadata(get_class($historyEntity));
$this->entityManager->getUnitOfWork()->computeChangeSet($classMeta, $historyEntity);
Profit
Hope this helps somebody!
Upvotes: 1