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
You might be interested in EntityAudit bundle.
It allows to configure which entities should be tracked. Then it introduces a concept of revisions of the database. Each revision has timestamp, username and list of entities affected.
Then, you can find all revisions that affect particular entity:
$revisions = $auditReader->findRevisions('AppBundle\Entity\Article', 1);
or instantiate it in a particular revision:
$oldArticle = $auditReader->find(
'AppBundle\Entity\Article',
$id = 1,
$rev = 2
);
so you can easily compare the current and the old state of the entity.
The bundle also ships with example views demonstrating how to display revision list, compare objects in different versions and more.