I want to track changes to a field of a Doctrine Entity. I use Symfony 2.5.0 and Doctrine 2.2.3.
So far i have an EventSubscriber
that subscribes to preUpdate
. Here I want to create a new Entity which stores the new and old value and holds a reference to the Entity that is updated.
The problem is, that I can't find a way to persist this new Entity. If I persist()
in preUpdate
and flush()
in postUpdate
, it works if I change only one Entity. If multiple Entities are changed, I get an error that the changeset is empty.
I tried fiddling with different events with different results. Blank pages, tracking entites do not get persisted etc.
I think that this should be a common use case - but I can't find examples.