Doctrine\ODM\PHPCR\UnitOfWork::computeChangeSets PHP Method

computeChangeSets() public method

Detects the changes that need to be persisted
public computeChangeSets ( )
    public function computeChangeSets()
    {
        foreach ($this->identityMap as $document) {
            $state = $this->getDocumentState($document);
            if ($state === self::STATE_MANAGED) {
                $class = $this->dm->getClassMetadata(get_class($document));
                $this->computeChangeSet($class, $document);
            }
        }
    }

Usage Example

Beispiel #1
0
 public function testComputeChangeSetForTranslatableDocument()
 {
     $root = $this->dm->find(null, 'functional');
     $c1 = new Comment();
     $c1->name = 'c1';
     $c1->parent = $root;
     $c1->setText('deutsch');
     $this->dm->persist($c1);
     $this->dm->bindTranslation($c1, 'de');
     $c1->setText('english');
     $this->dm->bindTranslation($c1, 'en');
     $this->dm->flush();
     $c2 = new Comment();
     $c2->name = 'c2';
     $c2->parent = $root;
     $c2->setText('deutsch');
     $this->dm->persist($c2);
     $this->dm->bindTranslation($c2, 'de');
     $c2->setText('english');
     $this->dm->bindTranslation($c2, 'en');
     $this->uow->computeChangeSets();
     $this->assertCount(1, $this->uow->getScheduledInserts());
     $this->assertCount(0, $this->uow->getScheduledUpdates());
 }
UnitOfWork