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

scheduleForInsert() public method

If the document already has an identifier, it will be added to the identity map.
public scheduleForInsert ( ClassMetadata $class, object $document )
$class Doctrine\ODM\MongoDB\Mapping\ClassMetadata
$document object The document to schedule for insertion.
    public function scheduleForInsert(ClassMetadata $class, $document)
    {
        $oid = spl_object_hash($document);
        if (isset($this->documentUpdates[$oid])) {
            throw new \InvalidArgumentException('Dirty document can not be scheduled for insertion.');
        }
        if (isset($this->documentDeletions[$oid])) {
            throw new \InvalidArgumentException('Removed document can not be scheduled for insertion.');
        }
        if (isset($this->documentInsertions[$oid])) {
            throw new \InvalidArgumentException('Document can not be scheduled for insertion twice.');
        }
        $this->documentInsertions[$oid] = $document;
        if (isset($this->documentIdentifiers[$oid])) {
            $this->addToIdentityMap($document);
        }
    }
UnitOfWork