Doctrine\ODM\MongoDB\UnitOfWork::scheduleForUpsert PHP Method

scheduleForUpsert() public method

Schedules a document for upsert into the database and adds it to the identity map
public scheduleForUpsert ( ClassMetadata $class, object $document )
$class Doctrine\ODM\MongoDB\Mapping\ClassMetadata
$document object The document to schedule for upsert.
    public function scheduleForUpsert(ClassMetadata $class, $document)
    {
        $oid = spl_object_hash($document);
        if ($class->isEmbeddedDocument) {
            throw new \InvalidArgumentException('Embedded document can not be scheduled for upsert.');
        }
        if (isset($this->documentUpdates[$oid])) {
            throw new \InvalidArgumentException('Dirty document can not be scheduled for upsert.');
        }
        if (isset($this->documentDeletions[$oid])) {
            throw new \InvalidArgumentException('Removed document can not be scheduled for upsert.');
        }
        if (isset($this->documentUpserts[$oid])) {
            throw new \InvalidArgumentException('Document can not be scheduled for upsert twice.');
        }
        $this->documentUpserts[$oid] = $document;
        $this->documentIdentifiers[$oid] = $class->getIdentifierValue($document);
        $this->addToIdentityMap($document);
    }
UnitOfWork