Commit 2da4270d authored by Ad Schellevis's avatar Ad Schellevis

force config file root to be named opnsense

parent 77d651cc
...@@ -253,12 +253,21 @@ class Config extends Singleton ...@@ -253,12 +253,21 @@ class Config extends Singleton
public function __toString() public function __toString()
{ {
// reformat XML (pretty print) // reformat XML (pretty print)
$configxml = dom_import_simplexml($this->simplexml);
$dom = new \DOMDocument('1.0'); $dom = new \DOMDocument('1.0');
$dom_sxe = $dom->importNode($configxml, true);
$dom->appendChild($dom_sxe); // make sure our root element is always called "opnsense"
$root = $dom->createElement('opnsense');
$dom->appendChild($root);
foreach ($this->simplexml as $node) {
$domNode = dom_import_simplexml($node);
$domNode = $root->ownerDocument->importNode($domNode, true);
$root->appendChild($domNode);
}
$dom->formatOutput = true; $dom->formatOutput = true;
$dom->preserveWhiteSpace = false; $dom->preserveWhiteSpace = false;
$dom->loadXML($dom->saveXML()); $dom->loadXML($dom->saveXML());
return $dom->saveXML(); return $dom->saveXML();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment