Finding out what changed via postUpdate listener in Symfony 2.1

后端 未结 4 1767
萌比男神i
萌比男神i 2021-02-20 18:14

I have a postUpdate listener and I\'d like to know what the values were prior to the update and what the values for the DB entry were after the update. Is there a way to do this

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-20 19:09

    Found the solution here. What I needed was actually part of preUpdate(). I needed to call getEntityChangeSet() on the LifecycleEventArgs.

    My code:

    public function preUpdate(Event\LifecycleEventArgs $eventArgs)
    {   
        $changeArray = $eventArgs->getEntityChangeSet();
    
        //do stuff with the change array
    
    }
    

提交回复
热议问题