Y
Y
Yakov Akulov2015-09-19 00:35:39
symfony
Yakov Akulov, 2015-09-19 00:35:39

Doctrine: how to get initial state of ManyToMany Collection field?

I do object changes logging using Doctrine.
For simple fields, everything is simple, I use UnitOfWork::getEntityChangeSet
But if the field contains a collection of objects, then I can not find the opportunity to compare the original value of the field with the state during postUpdate.
I found the methods UnitOfWork::getScheduledCollectionDeletions and UnitOfWork::getScheduledCollectionUpdates
But through them I can only get direct changes that will be written to the database, there is no diff there, as in changeSet.
Tell me where to dig, is there something ready for such cases in Doctrine ORM? How to make a decision yourself - I did not find a simple way, only perversions come to mind ...
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Romanenko, 2015-09-19
@slimus

In our project we use https://packagist.org/packages/simplethings/entity...
We set up which entities to monitor, the bundle itself saves everything, then we only look at the history

S
Sergey, 2015-09-19
Protko @Fesor

But if the field contains a collection of objects, then I can not find the opportunity to compare the original value of the field with the state during postUpdate.

The objects themselves in the collection continue to be compared through getEntityChangeSet, and collection changes are handled separately.
In general, tracking changes through the doctrine is a so-so idea, there are more convenient approaches like CQRS + Event Sourcing.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question