Doctrine\ODM\PHPCR\UnitOfWork::computeSingleDocumentChangeSet PHP Метод

computeSingleDocumentChangeSet() публичный Метод

Detects the changes for a single document
public computeSingleDocumentChangeSet ( object $document )
$document object
    public function computeSingleDocumentChangeSet($document)
    {
        $state = $this->getDocumentState($document);
        if ($state !== self::STATE_MANAGED && $state !== self::STATE_REMOVED) {
            throw new InvalidArgumentException('Document has to be managed for single computation ' . self::objToStr($document, $this->dm));
        }
        foreach ($this->scheduledInserts as $insertedDocument) {
            $class = $this->dm->getClassMetadata(get_class($insertedDocument));
            $this->computeChangeSet($class, $insertedDocument);
        }
        // Ignore uninitialized proxy objects
        if ($document instanceof Proxy && !$document->__isInitialized()) {
            return;
        }
        $oid = spl_object_hash($document);
        if (!isset($this->scheduledInserts[$oid])) {
            $class = $this->dm->getClassMetadata(get_class($document));
            $this->computeChangeSet($class, $document);
        }
    }

Usage Example

Пример #1
0
 /**
  * @see https://github.com/doctrine/phpcr-odm/issues/637
  * @covers Doctrine\ODM\PHPCR\UnitOfWork::computeSingleDocumentChangeSet
  */
 public function testComputeSingleDocumentChangeSetForRemovedDocument()
 {
     $object = new UoWUser();
     $object->username = "******";
     $object->id = '/somepath';
     $this->uow->scheduleRemove($object);
     // Should not throw "InvalidArgumentException: Document has to be managed for single computation"
     $this->uow->computeSingleDocumentChangeSet($object);
 }
UnitOfWork