Embedded document in the changeset Doctrine event listener

I use the doctrine event listener class to implement the registration of database events. I am using the postUpdate event. I have an embedded document in my mongoDB document. During the postUpdate event, when I call the method $uow->getDocumentChangeSet($entity), I get only the changed values ​​in the change set object. eg.

[0]=>
  object(Tyre24\ProductBundle\Document\Translations)#1178 (1) {
    ["translations":protected]=>
    object(Doctrine\ODM\MongoDB\PersistentCollection)#1216 (10) {
      ["snapshot":"Doctrine\ODM\MongoDB\PersistentCollection":private]=>
      array(0) {
      }
      ["coll":"Doctrine\ODM\MongoDB\PersistentCollection":private]=>
      object(Doctrine\Common\Collections\ArrayCollection)#1217 (1) {
        ["_elements":"Doctrine\Common\Collections\ArrayCollection":private]=>
        array(1) {
          [0]=>
          object(Tyre24\ProductBundle\Document\Translation)#1227 (3) {
            ["key":protected]=>
            string(11) "testkey_new"
            ["language":protected]=>
            string(5) "xx_XX"
            ["value":protected]=>
            string(9) "testvalue"
          }
        }
      }
    }
  }
  [1]=>
  object(Tyre24\ProductBundle\Document\Translations)#1178 (1) {
    ["translations":protected]=>
    object(Doctrine\ODM\MongoDB\PersistentCollection)#1216 (10) {
      ["snapshot":"Doctrine\ODM\MongoDB\PersistentCollection":private]=>
      array(0) {
      }
      ["coll":"Doctrine\ODM\MongoDB\PersistentCollection":private]=>
      object(Doctrine\Common\Collections\ArrayCollection)#1217 (1) {
        ["_elements":"Doctrine\Common\Collections\ArrayCollection":private]=>
        array(1) {
          [0]=>
          object(Tyre24\ProductBundle\Document\Translation)#1227 (3) {
            ["key":protected]=>
            string(11) "testkey_new"
            ["language":protected]=>
            string(5) "xx_XX"
            ["value":protected]=>
            string(9) "testvalue"
          }
        }
      }
    }
  }
}

Here, the first element of the array of change sets should reflect the older state of the embedded document, but it always shows the same (new) document in both indexes of the array. For documents without embedded documents, it works great. Any idea?

+4
source share
1

Doctrine ODM (mongo), ORM Doctrine, . , , ORM, .

OnFlush, , , . , , .

ORM, PostPersist, PostUpdate PostDelete, , .

PrePersist, PreUpdate PreDelete, : PreUpdate PreDelete , PrePersist , persist() /.

, OnFlush /, . , PostFlush. PostFlush , , . : - , , .

ORM . . , , . ( ), .

, , ORM, $uow->getScheduledEntityInsertions() .. , , ODM .

, , :

  • $uow->getScheduledDocumentInsertions();
  • $uow->getScheduledDocumentUpserts();
  • $uow->getScheduledDocumentUpdates();
  • $uow->getScheduledDocumentDeletions();
  • $uow->getScheduledCollectionDeletions();
  • $uow->getScheduledCollectionUpdates();

2 . / ($col->getOwner()) diff ($col->getInsertDiff() $col->getDeleteDiff()), , .

, !

+3

All Articles