Return the node for the given managed document.

@param object $document

@throws \RuntimeException If the node is not managed

@return NodeInterface
512224
public function getNodeForDocument($document)
    {
        $oid = $this->getObjectIdentifier($document);
        $this->assertDocumentExists($document);

        return $this->nodeMap[$this->documentNodeMap[$oid]];
    }
1161586
public function getXML(\DOMDocument $document)
    {
        $xml = $document->createElement(sprintf('%s:TransactionDetails', $this->namespace));

        $comments = $document->createElement('ns1:Comments');
        $comments->textContent = $this->comments;

        $xml->appendChild($comments);

        if (!empty($this->invoiceNumber)) {
            $invoiceNumber = $document->createElement('ns1:InvoiceNumber');
            $invoiceNumber->textContent = $this->invoiceNumber;

            $xml->appendChild($invoiceNumber);
        }

        return $xml;
    }
428800
public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
    {
        $element = parent::getDOM($doc, $majorVersion, $minorVersion);
        foreach ($this->_entry as $entry) {
            $element->appendChild($entry->getDOM($element->ownerDocument));
        }
        return $element;
    }
440820
public function build(DocumentInterface $document)
    {
        /**@var $document Invoice */
        $template = 'invoice'.$document->getUblVersion().'.xml.twig';

        return $this->render($template, $document);
    }
1207145
public function getNormalizedIdentifier($document)
    {
        if (is_scalar($document)) {
            throw new \InvalidArgumentException('Invalid argument, object or null required');
        }

        // the document is not managed
        if (!$document || !$this->getDocumentManager()->contains($document)) {
            return;
        }

        $values = $this->getIdentifierValues($document);

        return $values[0];
    }
1092091
public static function toPlainObject( $xml )
	{
		$parser	= new XML_DOM_Parser();
		$document	= $parser->parse( $xml );
		$rootNode	= array_shift( $document->getChildren() );
		$rootName	= $rootNode->getNodeName();
		$object->$rootName	= new stdClass();
		self::convertToObjectRecursive( $rootNode, $object->$rootName );
		return $object;
	}
127670
private function getResourceSegmentProperty($document)
    {
        $structure = $this->documentInspector->getStructureMetadata($document);

        if (!$structure) {
            return;
        }

        $property = $structure->getPropertyByTagName('sulu.rlp');

        if (!$property) {
            throw new \RuntimeException(
                sprintf(
                    'Structure "%s" does not have a "sulu.rlp" tag which is required for documents implementing the ' .
                    'ResourceSegmentBehavior. In "%s"',
                    $structure->name,
                    $structure->resource
                )
            );
        }

        return $property;
    }
797495
public static function getDocumentCompany($document)
    {
        return $document->getDataValue('firma') ? \FlexiPeeHP\FlexiBeeRO::uncode(
                $document->getDataValue('firma')) : null;
    }
1177338
public function parseDocument(\DOMDocument $document)
    {
        foreach ($this->registry[DocumentExtension::class] as $extension) {
            $doc = $extension->parseDocument($this, $document);
            if ($doc) {
                return $doc;
            }
        }

        return null;
    }
96333
public function index(Document $document)
    {
        $result = $this->client->request(
            'POST',
            "/{$this->indexName}/{$document->type}/{$document->id}",
            new Message(
                array(
                    'Content-Type' => 'application/json',
                ),
                $json = $this->serializer->getIndexDocument($document)
            )
        );

        $this->flush();

        if ($result->headers['status'] !== 201 && $result->headers['status'] !== 200) {
            throw new RuntimeException(
                'Wrong HTTP status received from Elasticsearch: ' . $result->headers['status']
            );
        }
    }
564807
public function getDocumentId($document, $throw = true)
    {
        $oid = is_object($document) ? spl_object_hash($document) : $document;
        if (empty($this->documentIds[$oid])) {
            if (!$throw) {
                return;
            }
            $msg = 'Document is not managed and has no id';
            if (is_object($document)) {
                $msg .= ': '.self::objToStr($document);
            }

            throw new PHPCRException($msg);
        }

        return $this->documentIds[$oid];
    }
796830
public function convert(DOMDocument $document)
    {
        // First
        $this->expandingConverter->convert($document);
        // Second
        $this->embedLinkingConverter->convert($document);

        return $document;
    }
920597
protected function asXml(DomDocument $document)
    {
        $root = $document->createElement($this->getTagName(), $this->content);
        $document->appendChild($root);

        foreach ($this->attributes as $name => $value) {
            $root->setAttribute($name, $value);
        }

        foreach ($this->children as $child) {
            $root->appendChild($child->asXml($document));
        }

        return $root;
    }
1322663
protected function replaceNode($string)
    {
        if (empty($string)) {
            $this->node->parentNode->removeChild($this->node);

            return null;
        }

        $newDocument = new Document($string);

        if ($newDocument->outertext !== $string) {
            throw new RuntimeException('Not valid HTML fragment');
        }

        $newNode = $this->node->ownerDocument->importNode($newDocument->getDocument()->documentElement, true);

        $this->node->parentNode->replaceChild($newNode, $this->node);
        $this->node = $newNode;

        return $this;
    }
760458
public function getDocumentActualData($document)
    {
        $class      = $this->dm->getClassMetadata(get_class($document));
        $actualData = [];

        foreach ($class->propertyMetadata as $name => $mapping) {
            // skip not saved attributes
            if ($mapping->notSaved) {
                continue;
            }

            $value = $mapping->getValue($document);

            if ($mapping->isMany() && $value !== null && !($value instanceof PersistentCollectionInterface)) {
                // If $actualData[$name] is not a Collection then use an ArrayCollection.
                if (!$value instanceof Collection) {
                    $value = new ArrayCollection($value);
                }

                // Inject PersistentCollection
                $coll = $this->dm->getConfiguration()->getPersistentCollectionFactory()->create($this->dm, $mapping, $value);
                $coll->setOwner($document, $mapping);
                $coll->setDirty(!$value->isEmpty());
                $mapping->setValue($document, $coll);
                $actualData[$name] = $coll;
            } else {
                $actualData[$name] = $value;
            }
        }

        return $actualData;
    }
1145383
private function hydrateEntity($document)
    {
        $class = $this->entityClass;
        $reflectionClass = new \ReflectionClass(AbstractDocument::class);
        $entity = new $class();

        if (!($entity instanceof AbstractDocument)) {
            throw new \Exception(sprintf('"%s" is not a subclass of "%s"', $this->entityClass, AbstractDocument::class));
        }

        $documentProperty = $reflectionClass->getProperty('document');
        $documentProperty->setAccessible(true);
        $documentProperty->setValue($entity, $document);

        return $entity;
    }
972720
public function getXML(\DOMDocument $document)
    {
        $xml = $document->createElement('ns2:RecurringPaymentInformation');

        if ($this->startDate !== null) {
            $startDate              = $document->createElement('ns2:RecurringStartDate');
            $startDate->textContent = $this->startDate->format('Ymd');
            $xml->appendChild($startDate);
        }

        if ($this->installmentCount !== null) {
            $installmentCount              = $document->createElement('ns2:InstallmentCount');
            $installmentCount->textContent = $this->installmentCount;
            $xml->appendChild($installmentCount);
        }

        if ($this->installmentFrequency !== null) {
            $installmentFrequency              = $document->createElement('ns2:InstallmentFrequency');
            $installmentFrequency->textContent = $this->installmentFrequency;
            $xml->appendChild($installmentFrequency);
        }

        if ($this->installmentFrequency !== null) {
            $installmentPeriod              = $document->createElement('ns2:InstallmentPeriod');
            $installmentPeriod->textContent = $this->installmentPeriod;
            $xml->appendChild($installmentPeriod);
        }

        return $xml;
    }