mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Get entity change sets - do not change internal unit of work state #5493
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @vasekjares on GitHub (Apr 6, 2017).
Originally assigned to: @Ocramius on GitHub.
It would be great to have a method to get entity change set without changing internal unit of work state:
$user = $em->find(User::class, 1);$user->setAge(10);$user->setName('John');$em->getUnitOfWork()->recomputeChangeSets();$logger->log(User::class, 1, $em->getUnitOfWork()->getEntityChangeSet($user));$em->flush();Code above works great, but issue is that it changes internal state of UoW. (updates original snapshots). So if I change code to:
$user = $em->find(User::class, 1);$user->setAge(10);$user->setName('John');$em->getUnitOfWork()->recomputeChangeSets();$logger->log(User::class, 1, $em->getUnitOfWork()->getEntityChangeSet($user));$user->setEnabled(true); //previous value was false$em->flush();Only "enabled" property is persisted. Changes of age and name are forgotten (unless I recompute change sets manually again)
It would be great to have method which just calculates change sets and returns them (with not internal changes to UoW)