Doctrine Extension Loggable - log old values instead of new ones of field

754 Views Asked by At

I implemented the Loggable extensions of Doctrine. But now I have the following case. I want to track "status" of object. But the objects already exist in my db with corresponding status for each of them. When I update one, in the log_entry is inserted the first log for an object with the new value for its status. (Let say I chnage status from active to suspended and in the log entry is inserted suspended)

From this moment I cannot revert the "active" status, becouse it is not recorded nowhere. I can deal with that with several ways, but is there some option for that Loggable Extension that instead of inserting new version, as a lest record for object in logs to store the current version, before changes happen?

1

There are 1 best solutions below

1
On

You can override getObjectChangeSetData from LoggableListener.

Old values are stored there in $changes array.