An array to which fact information should be added
@param array $document (passed by reference)
487743
private function addFacts( &$document )
	{
		foreach ( $this->facts as $formulaFactKey => $formulaFacts )
		{
			foreach ( $formulaFacts as $factIndex => $fact )
			{
				/**
				 * @var QName $conceptQName
				 */
				$conceptQName = $fact['concept'];
				$concept = "{$conceptQName->prefix}:{$conceptQName->localName}";

				$entry = array();
				$entry[] = "<$concept ";

				if ( isset( $this->sources[ $formulaFactKey ] ) )
				{
					$attributesIterator = AttributeNodeIterator::fromNodeTest( null, null, XPath2NodeIterator::Create( $this->sources[ $formulaFactKey ] ) );
					$attributesIterator->Reset();
					$attributesIterator->MoveNext();
					foreach ( $attributesIterator as $attribute )
					{
						// Ignore the standard ones
						if ( empty( $attribute->getNamespaceURI() ) )
						{
							switch ( $attribute->getLocalName() )
							{
								case "contextRef":
								case "unitRef":
								case "decimals":
								case "precision":
									continue 2;

								default:
									break;
							}
						}
						else if ( $attribute->getNamespaceURI() == \XBRL_Constants::$standardNamespaces[ STANDARD_PREFIX_SCHEMA_INSTANCE ] )
						{
							if ( $attribute->getLocalName() == "nil" ) continue 2;
						}

						// Otherwise add an attribute
						$name = $attribute->getPrefix()
							? "{$attribute->getPrefix()}:{$attribute->getLocalName()}"
							: $attribute->getLocalName();
						$entry[] = "$name=\"{$attribute->getValue()}\"";
					}
				}

				// // Get the node if it exists
				// if ( isset( $this->vars[ $formulaFactKey ][ $factIndex ] ) )
				// {
				// 	foreach ( $this->vars[ $formulaFactKey ][ $factIndex ] as /* @var DOMXPathNavigator $var */ $var )
				// 	{
				// 		// $var will be a node iterator if the variable is bind as a sequence
				// 		if ( ! $var instanceof DOMXPathNavigator ) continue;
				// 		if ( $var->getNamespaceURI() != $fact['concept']->namespaceURI || $var->getLocalName() != $fact['concept']->localName )
				// 		{
				// 			continue;
				// 		}
                //
				// 		if ( ! $var instanceof DOMXPathNavigator || ! $var->getHasAttributes() ) continue;
				// 		// Test 46210 V-01 fails because an ID attribute should NOT be added
				// 		// Test 47212 V-01 fails because an ID attribute SHOULD be added.  What is the criteria?
				// 		if ( true )
				// 		{
				// 			$attributesIterator = AttributeNodeIterator::fromNodeTest( null, null, XPath2NodeIterator::Create( $var ) );
				// 			$attributesIterator->Reset();
				// 			foreach ( $attributesIterator as $attribute )
				// 			{
				// 				// Ignore the standard ones
				// 				if ( empty( $attribute->getNamespaceURI() ) )
				// 				{
				// 					switch ( $attribute->getLocalName() )
				// 					{
				// 						case "contextRef":
				// 						case "unitRef":
				// 						case "decimals":
				// 						case "precision":
				// 							continue 2;
                //
				// 						default:
				// 							break;
				// 					}
				// 				}
				// 				else if ( $attribute->getNamespaceURI() == \XBRL_Constants::$standardNamespaces[ STANDARD_PREFIX_SCHEMA_INSTANCE ] )
				// 				{
				// 					if ( $attribute->getLocalName() == "nil" ) continue 2;
				// 				}
                //
				// 				// Otherwise add an attribute
				// 				$name = $attribute->getPrefix()
				// 					? "{$attribute->getPrefix()}:{$attribute->getLocalName()}"
				// 					: $attribute->getLocalName();
				// 				$entry[] = "$name=\"{$attribute->getValue()}\"";
				// 			}
				// 		}
				// 	}
				// }

				$entry[] = "contextRef=\"{$fact['contextRef']}\"";

				if ( isset( $fact['unitRef'] ) )
				{
					$entry[] = "unitRef=\"{$fact['unitRef']}\"";
				}
				if ( isset( $fact['decimals'] ) )
				{
					$entry[] = "decimals=\"{$fact['decimals']}\"";
				}
				if ( isset( $fact['precision'] ) )
				{
					$entry[] = "precision=\"{$fact['precision']}\"";
				}

				if ( is_null( $fact['value'] ) )
				{
					$entry[] = "xsi:nil=\"true\"";
					$entry[] = "/>";
				}
				else
				{
					$value = htmlspecialchars( $fact['value'], ENT_XML1 | ENT_COMPAT, 'UTF-8' );
					$entry[] = ">$value</$concept>";
				}

				$document[] = "  " . implode( " ", $entry );
			}
		}
	}
1010235
public function addDocuments(
        $documents,
        $allowDups = false,
        $overwritePending = true,
        $overwriteCommitted = true,
        $commitWithin = 0
    ) {
        $overwriteVal = $allowDups ? 'false' : 'true';
        $commitWithin = (int) $commitWithin;
        $commitWithinString = $commitWithin > 0 ? " commitWithin=\"{$commitWithin}\"" : '';

        $rawPost = "<add overwrite=\"{$overwriteVal}\"{$commitWithinString}>";
        foreach ($documents as $document) {
            if ($document instanceof \Apache_Solr_Document) {
                $rawPost .= $this->_documentToXmlFragment($document);
            }
        }
        $rawPost .= '</add>';

        return $this->add($rawPost);
    }
19194
public function persist($document)
    {
        $documentArray = $this->converter->convertToArray($document);
        $type = $this->getMetadataCollector()->getDocumentType(get_class($document));

        $this->bulk('index', $type, $documentArray);
    }
1148332
public function persist($collection, array $document)
    {
        

        if ($collection instanceof Collection) {
            $collectionName = $collection->getName();
        } else {
            $collectionName = $collection;
            $collection = static::factory($collection);
        }
        
        $data = $this->marshall($document);
        $result = false;

        
        if (!isset($document['$id'])) {
            $id = $this->insert($collectionName, $data);
            if ($id) {
                $data['$id'] = $id;
                $result = $data;
            }
        } else {
            $data['id'] = $document['$id'];
            unset($data['$id']);
            $result = $this->update($collectionName, $data);

            if ($result) {
                $result = $data;
            }
        }

        return $this->unmarshall($result);
    }
1042461
private function addToData(array $representation): void
    {
        if ($this->isDataAnArray() === true) {
            $this->data[DocumentInterface::KEYWORD_DATA][] = $representation;

            return;
        }

        // check data has not been added yet
        \assert(\array_key_exists(DocumentInterface::KEYWORD_DATA, $this->data) === false);
        $this->data[DocumentInterface::KEYWORD_DATA] = $representation;
    }
1320924
public function setDocument(Document $document): self
    {
        $this->_data = $document;

        $metadata = $this->_getMetadata($document);

        $this->setMetadata($metadata);

        return $this;
    }
1120528
function addDocSpecification( $text )
    {
        $docSpec = array_pop( $this->PreStack );
        $this->DocSpecification[] = array ( 'docSpec' => $docSpec,
                                            'text' => $text );
        $this->PreStack[] = $docSpec;
    }
131665
public function addInfo($info) : void
    {
        Assert::isInstanceOfAny($info, [Chunk::class, KeyInfo::class]);
        $this->info[] = $info;
    }
631362
void addDocument(Document doc) throws IOException
   {
      update(Collections.<String> emptyList(), Arrays.asList(new Document[]{doc}));
   }
573642
void addDocuments(final Document[] docs) throws IOException
   {
      final IndexWriter writer = getIndexWriter();

      IOException ioExc = null;
      try
      {
         for (Document doc : docs)
         {
            try
            {
               writer.addDocument(doc);
            }
            catch (Throwable e) //NOSONAR
            {
               if (ioExc == null)
               {
                  if (e instanceof IOException)
                  {
                     ioExc = (IOException)e;
                  }
                  else
                  {
                     ioExc = Util.createIOException(e);
                  }
               }

               log.warn("Exception while inverting document", e);
            }
         }
      }
      finally
      {
         invalidateSharedReader();
      }

      if (ioExc != null)
      {
         throw ioExc;
      }
   }
1158131
public function setOriginalDocumentData($document, array $data)
    {
        $oid                              = spl_object_hash($document);
        $this->originalDocumentData[$oid] = $data;

        unset($this->documentChangeSets[$oid]);
    }
368885
public function insert(array &$doc)
    {
        if (isset($doc['_id'])) {
            $clone = $doc;
            unset($clone['_id']);

            $response = $this->client->request('PUT', "/{$this->name}/{$doc['_id']}", [
                'body'    => JSONEncoder::encode($clone),
                'headers' => ['Content-Type' => 'application/json'],
            ]);
        } else {
            $response = $this->client->request('POST', "/{$this->name}/", [
                'body'    => JSONEncoder::encode($doc),
                'headers' => ['Content-Type' => 'application/json'],
            ]);
        }

        if (201 !== $response->getStatusCode()) {
            throw new Exception('Unable to save document');
        }

        $value = JSONEncoder::decode((string) $response->getBody());

        $doc['_id'] = $value['id'];
        $doc['_rev'] = $value['rev'];
    }
646782
public function hasDocument($document)
    {
        $oid = $this->getObjectIdentifier($document);

        return isset($this->documentMap[$oid]);
    }
1166850
private function cascadeDetach($document, array &$visited)
    {
        $class = $this->dm->getClassMetadata(get_class($document));
        foreach ($class->propertyMetadata as $mapping) {
            if (!$mapping->isCascadeDetach) {
                continue;
            }
            $relatedDocuments = $class->getPropertyMetadata($mapping->name)->getValue($document);
            if (($relatedDocuments instanceof Collection || is_array($relatedDocuments))) {
                if ($relatedDocuments instanceof PersistentCollectionInterface) {
                    // Unwrap so that foreach() does not initialize
                    $relatedDocuments = $relatedDocuments->unwrap();
                }
                foreach ($relatedDocuments as $relatedDocument) {
                    $this->doDetach($relatedDocument, $visited);
                }
            } elseif ($relatedDocuments !== null) {
                $this->doDetach($relatedDocuments, $visited);
            }
        }
    }
1201923
public function includesReferenceTo(object $document) : self
    {
        $this->requiresCurrentField();
        $mapping   = $this->getReferenceMapping();
        $reference = $this->dm->createReference($document, $mapping);
        $storeAs   = $mapping['storeAs'] ?? null;
        $keys      = [];

        switch ($storeAs) {
            case ClassMetadata::REFERENCE_STORE_AS_ID:
                $this->query[$mapping['name']] = $reference;
                return $this;
                break;

            case ClassMetadata::REFERENCE_STORE_AS_REF:
                $keys = ['id' => true];
                break;

            case ClassMetadata::REFERENCE_STORE_AS_DB_REF:
            case ClassMetadata::REFERENCE_STORE_AS_DB_REF_WITH_DB:
                $keys = ['$ref' => true, '$id' => true, '$db' => true];

                if ($storeAs === ClassMetadata::REFERENCE_STORE_AS_DB_REF) {
                    unset($keys['$db']);
                }

                if (isset($mapping['targetDocument'])) {
                    unset($keys['$ref'], $keys['$db']);
                }
                break;

            default:
                throw new InvalidArgumentException(sprintf('Reference type %s is invalid.', $storeAs));
        }

        foreach ($keys as $key => $value) {
            $this->query[$mapping['name']]['$elemMatch'][$key] = $reference[$key];
        }

        return $this;
    }
674706
public function add($fact)
    {
        if (is_string($fact)) {
            $this->collection[] = new Fact(array('fact'=>$fact));
        } elseif (is_object($fact) && $fact instanceof Fact) {
            $this->collection[] = $fact;
        }

        return $this;
    }
950636
public function insert(array $values)
    {
        // Since every insert gets treated like a batch insert, we will have to detect
        // if the user is inserting a single document or an array of documents.
        $batch = true;

        foreach ($values as $value) {
            // As soon as we find a value that is not an array we assume the user is
            // inserting a single document.
            if (!is_array($value)) {
                $batch = false;
                break;
            }
        }

        if (!$batch) {
            $values = [$values];
        }

        // Batch insert
        $result = $this->collection->insertMany($values);

        return (1 == (int) $result->isAcknowledged());
    }