mongodb - Doctrine EventListener onFlush access to old Document -


i can access updated document in onflush eventlisterner of doctrine2. want complete old document store elsewhere old state.

   public function onflush(onflusheventargs $eventargs)     {         $dm = $eventargs->getdocumentmanager();          $uow = $dm->getunitofwork();         foreach ($uow->getscheduleddocumentupdates() $document) {             // $document updated document             // $changeset contains new , old values             $changeset = $uow->getdocumentchangeset($document);              // want whole old document object $olddocument         }            } 

how can access old document not change set?

just use preupdate event. example:

public function preupdate(preupdateeventargs $event) {     $entity = $event->getentity(); // whole entity     $changeset = $event->getentitychangeset(); // changed properties      // check if password has been changed     if ($event->haschangedfield('password')) {          // stuff     }      /* ... */ } 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -