@param Document $document

@return void
962316
public function processDocument(Document $document)
    {
        /** @var TableOfContents[] $tocs */
        $tocs = [];

        $headings = [];

        $document->heading_ids = [];
        $walker = $document->walker();
        while ($event = $walker->next()) {
            $node = $event->getNode();

            if ($node instanceof TableOfContents && !$event->isEntering()) {
                $tocs[] = $node;
                continue;
            }

            if (!($node instanceof Heading) || !$event->isEntering()) {
                continue;
            }

            $this->ensureHeadingHasId($document, $node);
            $headings[] = new Entry($node);
        }

        if (count($headings) && (count($tocs) || $this->hasAutoTOC())) {
            $generated = $this->generate($headings);

            if (count($tocs)) {
                foreach ($tocs as $toc) {
                    $toc->appendChild($this->render($generated->getChildren()));
                }
            } else {
                $document->prependChild($this->render($generated->getChildren()));
            }
        }
    }
305663
void remove_document(Document doc)
    {
        for (Document<K> document : documents_)
        {
            if (document.equals(doc))
            {
                remove_document(doc);
                return;
            }
        }
    }
1034095
public function prepareUpdateData($document)
    {
        $class     = $this->dm->getClassMetadata(get_class($document));
        $changeset = $this->uow->getDocumentChangeSet($document);

        $updateData = [];
        foreach ($changeset as $fieldName => $change) {
            $mapping = $class->fieldMappings[$fieldName];

            // skip non embedded document identifiers
            if (! $class->isEmbeddedDocument && ! empty($mapping['id'])) {
                continue;
            }

            [$old, $new] = $change;

            // Scalar fields
            if (! isset($mapping['association'])) {
                if ($new === null && $mapping['nullable'] !== true) {
                    $updateData['$unset'][$mapping['name']] = true;
                } else {
                    if ($new !== null && isset($mapping['strategy']) && $mapping['strategy'] === ClassMetadata::STORAGE_STRATEGY_INCREMENT) {
                        $operator = '$inc';
                        $value    = Type::getType($mapping['type'])->convertToDatabaseValue($new - $old);
                    } else {
                        $operator = '$set';
                        $value    = $new === null ? null : Type::getType($mapping['type'])->convertToDatabaseValue($new);
                    }

                    $updateData[$operator][$mapping['name']] = $value;
                }

            // @EmbedOne
            } elseif (isset($mapping['association']) && $mapping['association'] === ClassMetadata::EMBED_ONE) {
                // If we have a new embedded document then lets set the whole thing
                if ($new && $this->uow->isScheduledForInsert($new)) {
                    $updateData['$set'][$mapping['name']] = $this->prepareEmbeddedDocumentValue($mapping, $new);

                // If we don't have a new value then lets unset the embedded document
                } elseif (! $new) {
                    $updateData['$unset'][$mapping['name']] = true;

                // Update existing embedded document
                } else {
                    $update = $this->prepareUpdateData($new);
                    foreach ($update as $cmd => $values) {
                        foreach ($values as $key => $value) {
                            $updateData[$cmd][$mapping['name'] . '.' . $key] = $value;
                        }
                    }
                }

            // @ReferenceMany, @EmbedMany
            } elseif (isset($mapping['association']) && $mapping['type'] === 'many' && $new) {
                if (CollectionHelper::isAtomic($mapping['strategy']) && $this->uow->isCollectionScheduledForUpdate($new)) {
                    $updateData['$set'][$mapping['name']] = $this->prepareAssociatedCollectionValue($new, true);
                } elseif (CollectionHelper::isAtomic($mapping['strategy']) && $this->uow->isCollectionScheduledForDeletion($new)) {
                    $updateData['$unset'][$mapping['name']] = true;
                    $this->uow->unscheduleCollectionDeletion($new);
                } elseif (CollectionHelper::isAtomic($mapping['strategy']) && $this->uow->isCollectionScheduledForDeletion($old)) {
                    $updateData['$unset'][$mapping['name']] = true;
                    $this->uow->unscheduleCollectionDeletion($old);
                } elseif ($mapping['association'] === ClassMetadata::EMBED_MANY) {
                    foreach ($new as $key => $embeddedDoc) {
                        if ($this->uow->isScheduledForInsert($embeddedDoc)) {
                            continue;
                        }

                        $update = $this->prepareUpdateData($embeddedDoc);
                        foreach ($update as $cmd => $values) {
                            foreach ($values as $name => $value) {
                                $updateData[$cmd][$mapping['name'] . '.' . $key . '.' . $name] = $value;
                            }
                        }
                    }
                }

            // @ReferenceOne
            } elseif (isset($mapping['association']) && $mapping['association'] === ClassMetadata::REFERENCE_ONE) {
                if (isset($new) || $mapping['nullable'] === true) {
                    $updateData['$set'][$mapping['name']] = $new === null ? null : $this->prepareReferencedDocumentValue($mapping, $new);
                } else {
                    $updateData['$unset'][$mapping['name']] = true;
                }
            }
        }
        // collections that aren't dirty but could be subject to update are
        // excluded from change set, let's go through them now
        foreach ($this->uow->getScheduledCollections($document) as $coll) {
            $mapping = $coll->getMapping();
            if (CollectionHelper::isAtomic($mapping['strategy']) && $this->uow->isCollectionScheduledForUpdate($coll)) {
                $updateData['$set'][$mapping['name']] = $this->prepareAssociatedCollectionValue($coll, true);
            } elseif (CollectionHelper::isAtomic($mapping['strategy']) && $this->uow->isCollectionScheduledForDeletion($coll)) {
                $updateData['$unset'][$mapping['name']] = true;
                $this->uow->unscheduleCollectionDeletion($coll);
            }
            // @ReferenceMany is handled by CollectionPersister
        }
        return $updateData;
    }
120951
public function unlock($document)
    {
        if (!is_object($document)) {
            throw new \InvalidArgumentException(gettype($document));
        }
        $this->unitOfWork->unlock($document);
    }
1240570
public function addDocument(\Innova\CollecticielBundle\Entity\Document $documents)
    {
        $this->documents[] = $documents;

        return $this;
    }
682832
public function setDocumentChangeSet(object $document, array $changeset) : void
    {
        $this->documentChangeSets[spl_object_hash($document)] = $changeset;
    }
150275
public function unscheduleOrphanRemoval(object $document) : void
    {
        $oid = spl_object_hash($document);
        unset($this->orphanRemovals[$oid]);
    }
1168914
public function deleteDocument(Document $document)
    {
        if (Document::DOCUMENT_TYPE_FILE === $document->getType()) {
            $data = $document->getFile();

            if (isset($data['url'])) {
                $this->fileSystem->remove($this->filesDir.DIRECTORY_SEPARATOR.$data['url']);
            }
        }
        $this->om->remove($document);
        $this->om->flush();

        $this->eventDispatcher->dispatch('log', new LogDocumentDeleteEvent($document->getDrop()->getDropzone(), $document->getDrop(), $document));
    }
698700
public function manipulate(\DOMDocument $document, LayoutInterface $layout): void
    {
        $host = '//' . $layout->getSource()->getHost();

        /** @var \DOMElement $anchor */
        foreach ($document->getElementsByTagName('a') as $anchor) {
            $this->replaceElementAttributeWithAbsoluteUri($anchor, 'href', $host);
        }

        /** @var \DOMElement $anchor */
        foreach ($document->getElementsByTagName('link') as $anchor) {
            $this->replaceElementAttributeWithAbsoluteUri($anchor, 'href', $host);
        }

        /** @var \DOMElement $anchor */
        foreach ($document->getElementsByTagName('img') as $anchor) {
            $this->replaceElementAttributeWithAbsoluteUri($anchor, 'src', $host);
        }

        /** @var \DOMElement $anchor */
        foreach ($document->getElementsByTagName('script') as $anchor) {
            $this->replaceElementAttributeWithAbsoluteUri($anchor, 'src', $host);
        }

        $xPath = new \DOMXPath($document);
        /** @var \DOMComment[] $comments */
        $comments = $xPath->query('//comment()');
        foreach ($comments as $comment) {
            $this->replaceCommentWithAbsoluteUri($comment, $host);
        }
    }
870762
public function scheduleForDelete(object $document) : void
    {
        $oid = spl_object_hash($document);

        if (isset($this->documentInsertions[$oid])) {
            if ($this->isInIdentityMap($document)) {
                $this->removeFromIdentityMap($document);
            }
            unset($this->documentInsertions[$oid]);
            return; // document has not been persisted yet, so nothing more to do.
        }

        if (! $this->isInIdentityMap($document)) {
            return; // ignore
        }

        $this->removeFromIdentityMap($document);
        $this->documentStates[$oid] = self::STATE_REMOVED;

        if (isset($this->documentUpdates[$oid])) {
            unset($this->documentUpdates[$oid]);
        }
        if (isset($this->documentDeletions[$oid])) {
            return;
        }

        $this->documentDeletions[$oid] = $document;
    }
484731
public function update($document): void
    {
        $class = $this->dm->getClassMetadata(get_class($document));
        $data = $this->prepareUpdateData($document);
        $id = $class->getSingleIdentifier($document);

        $this->collection->update((string) $id, $data['body'], $data['script']);
    }
11124
public function canHandle(Document $document) : bool
    {
        return false !== strpos($document->getDOMDocument()->documentElement->tagName, static::ROOT_NODE_TAGNAME);
    }
89985
public function delete($document)
    {
        $qb         = $this->dm->createQueryBuilder($this->class->name);
        $identifier = $this->uow->getDocumentIdentifier($document);

        $qb->delete();
        $qb->setIdentifier($identifier);

        if ($this->class->isLockable) {
            $qb->attr($this->class->lockMetadata->name)->exists(false);
        }

        try {
            $qb->getQuery()->execute();
        } catch (\Aws\DynamoDb\Exception\DynamoDbException $e) {
            if (
                ($this->class->isVersioned || $this->class->isLockable) &&
                $e->getAwsErrorCode() === 'ConditionalCheckFailedException'
            ) {
                throw LockException::lockFailed($document);
            }

            throw $e;
        }
    }
1074191
public function addDocument(Zend_Search_Lucene_Document $document)
    {
        /**
 * Zend_Search_Lucene_Index_SegmentWriter_DocumentWriter 
*/
        include_once 'Zend/Search/Lucene/Index/SegmentWriter/DocumentWriter.php';

        if ($this->_currentSegment === null) {
            $this->_currentSegment =
                new Zend_Search_Lucene_Index_SegmentWriter_DocumentWriter($this->_directory, $this->_newSegmentName());
        }
        $this->_currentSegment->addDocument($document);

        if ($this->_currentSegment->count() >= $this->maxBufferedDocs) {
            $this->commit();
        }

        $this->_maybeMergeSegments();

        $this->_versionUpdate++;
    }
1337146
public function init(Document $document)
	{
		$this->title = $document->getTitle();
		$this->address = $this->getAddress($document, $this->serviceLocator);
		
		return $this;
	}
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);
    }
1114613
public function remove($documents)
    {
        if (!is_array($documents)) {
            $documents = array($documents);
        }

        $remove =& $this->getArchive()->getByRef('remove', array());
        foreach ($documents as $document) {
            $remove[] = $document;
        }
    }