Schedules a document for being updated.

@param object $document The document to schedule for being updated.
@throws \InvalidArgumentException
11383
public function scheduleForUpdate($document)
    {
        $oid = spl_object_hash($document);
        if ( ! isset($this->documentIdentifiers[$oid])) {
            throw new \InvalidArgumentException("Document has no identity.");
        }
        if (isset($this->documentDeletions[$oid])) {
            throw new \InvalidArgumentException("Document is removed.");
        }

        if ( ! isset($this->documentUpdates[$oid]) && ! isset($this->documentInsertions[$oid]) && ! isset($this->documentUpserts[$oid])) {
            $this->documentUpdates[$oid] = $document;
        }
    }
1292135
public function put($docs)
    {
        if($docs instanceof Document) {
            $this->obj_gateway->put([$docs]);
        } elseif (is_array($docs)) {
            $this->obj_gateway->put($docs);
        } else {
            throw new \InvalidArgumentException('Parameter must be one or more \Search\Document objects');
        }
    }
978974
public function setDocumentValue($document, $property, $value)
    {
        $setter = \Closure::bind(function ($document, $property, $value) {
                $document->$property = $value;
            }, null, $document
        );
        $setter($document, $property, $value);
    }
905580
private function invalidateDocumentStructure($document)
    {
        if (!$this->cacheManager) {
            return;
        }

        $structureBridge = $this->structureManager->wrapStructure(
            $this->documentInspector->getMetadata($document)->getAlias(),
            $this->documentInspector->getStructureMetadata($document)
        );
        $structureBridge->setDocument($document);

        $this->cacheManager->invalidateTag($document->getUuid());
    }
448677
private function computeScheduleInsertsChangeSets() : void
    {
        foreach ($this->documentInsertions as $document) {
            $class = $this->dm->getClassMetadata(get_class($document));
            if ($class->isEmbeddedDocument) {
                continue;
            }

            $this->computeChangeSet($class, $document);
        }
    }
323325
public function setDocumentRoot($path)
    {
        if (file_exists($path)) {
            $this->document_root = realpath($path);
        } elseif (file_exists(DirectoryHelper::slashDirname($this->getRootDirectory()) . $path)) {
            $this->document_root = DirectoryHelper::slashDirname($this->getRootDirectory()) . $path;
        } else {
            throw new \InvalidArgumentException(
                sprintf('Document root path "%s" doesn\'t exist!', $path)
            );
        }
        return $this;
    }
1138957
public function contains($document)
    {
        if (!is_object($document)) {
            throw new InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
        }

        return $this->unitOfWork->contains($document);
    }
150275
public function unscheduleOrphanRemoval(object $document) : void
    {
        $oid = spl_object_hash($document);
        unset($this->orphanRemovals[$oid]);
    }
1243109
public function preUpdate(ClassMetadata $class, object $document) : void
    {
        if (! empty($class->lifecycleCallbacks[Events::preUpdate])) {
            $class->invokeLifecycleCallbacks(Events::preUpdate, $document, [new PreUpdateEventArgs($document, $this->dm, $this->uow->getDocumentChangeSet($document))]);
            $this->uow->recomputeSingleDocumentChangeSet($class, $document);
        }
        $this->evm->dispatchEvent(Events::preUpdate, new PreUpdateEventArgs($document, $this->dm, $this->uow->getDocumentChangeSet($document)));
        $this->cascadePreUpdate($class, $document);
    }
350143
public function setFieldValue(object $document, string $field, $value) : void
    {
        if ($document instanceof GhostObjectInterface && ! $document->isProxyInitialized()) {
            //property changes to an uninitialized proxy will not be tracked or persisted,
            //so the proxy needs to be loaded first.
            $document->initializeProxy();
        }

        $this->reflFields[$field]->setValue($document, $value);
    }
705010
public function addDocument($document) {
		if(is_array($document)) {
			$this->addDocumentArray($document);
		} elseif ($document instanceof Document) {
			$this->addDocumentObject($document);
		}
	}
497786
private function cascadePostUpdate(ClassMetadata $class, object $document) : void
    {
        foreach ($class->getEmbeddedFieldsMappings() as $mapping) {
            $value = $class->reflFields[$mapping['fieldName']]->getValue($document);
            if ($value === null) {
                continue;
            }
            $values = $mapping['type'] === ClassMetadata::ONE ? [$value] : $value;

            foreach ($values as $entry) {
                if (empty($this->uow->getDocumentChangeSet($entry)) && ! $this->uow->hasScheduledCollections($entry)) {
                    continue;
                }
                $entryClass = $this->dm->getClassMetadata(get_class($entry));
                $event      = $this->uow->isScheduledForInsert($entry) ? Events::postPersist : Events::postUpdate;
                $entryClass->invokeLifecycleCallbacks($event, $entry, [new LifecycleEventArgs($entry, $this->dm)]);
                $this->evm->dispatchEvent($event, new LifecycleEventArgs($entry, $this->dm));

                $this->cascadePostUpdate($entryClass, $entry);
            }
        }
    }
709724
public function persist(object $document) : void
    {
        $class = $this->dm->getClassMetadata(get_class($document));
        if ($class->isMappedSuperclass || $class->isQueryResultDocument) {
            throw MongoDBException::cannotPersistMappedSuperclass($class->name);
        }
        $visited = [];
        $this->doPersist($document, $visited);
    }
311463
private function invalidateDocumentUrls($document, $locale)
    {
        if (!$this->cacheManager) {
            return;
        }

        foreach ($this->getLocaleUrls($document, $locale) as $url) {
            $this->cacheManager->invalidatePath($url);
        }
    }
406195
public function setRunningFile($file)
    {
        if (false === is_file($file)) {
            throw InvalidArgumentException::create(
                'The file "%s" is not a file or it does not exist.',
                $file
            );
        }

        $this->runningFile = $file;
    }
1169033
public function store($document)
    {
        if (is_null($document->get('_dateCreated'))) {
            $document->set('_dateCreated', date('Y-m-d H:i:s'));
        }
        $document->set('_dateUpdated', date('Y-m-d H:i:s'));

        if ($document->getIsNew()) {
            if (method_exists($document, 'onCreate')) {
                $document->onCreate();
            }

            return $this->_documentHandler->save($this->_collectionName, $document);
        } else {
            if (method_exists($document, 'onUpdate')) {
                $document->onUpdate();
            }

            return $this->_documentHandler->replace($document);
        }
    }
1274937
public function unlock($document)
    {
        $id = $this->uow->getDocumentIdentifier($document);
        $criteria = array('_id' => $this->class->getDatabaseIdentifierValue($id));
        $lockMapping = $this->class->fieldMappings[$this->class->lockField];
        $this->collection->update($criteria, array('$unset' => array($lockMapping['name'] => true)));
        $this->class->reflFields[$this->class->lockField]->setValue($document, null);
    }