Jarves\Configuration\Model::appendXml PHP Method

appendXml() public method

Appends the xml structure with our values.
public appendXml ( DOMNode $node, boolean $printDefaults = false, boolean $printComments = false ) : DOMElement
$node DOMNode
$printDefaults boolean
$printComments boolean
return DOMElement
    public function appendXml(\DOMNode $node, $printDefaults = false, $printComments = false)
    {
        $doc = $node instanceof \DOMDocument ? $node : $node->ownerDocument;
        if ($printComments) {
            $this->lastRootElementComment = $doc->createComment($this->docBlock);
            $node->appendChild($this->lastRootElementComment);
        }
        try {
            $rootNode = $doc->createElement($this->rootName);
            $node->appendChild($rootNode);
        } catch (\DOMException $e) {
            throw new \Exception(sprintf('Can not create xml element `%s`', $this->rootName), 0, $e);
        }
        foreach ($this as $key => $val) {
            $this->appendXmlProperty($key, $rootNode, $printDefaults, $printComments);
        }
        foreach ($this->additionalNodes as $k => $v) {
            $this->appendXmlValue($k, $v, $rootNode, $printDefaults, $printComments);
        }
        foreach ($this->additionalAttributes as $k => $v) {
            $rootNode->setAttribute($k, (string) $v);
        }
        if ($this->lastRootElementComment && !$this->lastRootElementComment->substringData(0, 1)) {
            $node->removeChild($this->lastRootElementComment);
        }
        return $rootNode;
    }