/** * Recursively initializes the configuration instance with the data from the * passed SimpleXMLElement. * * @param \SimpleXMLElement $node The node to load the data from * * @return \TechDivision\Configuration\Interfaces\ConfigurationInterface The node instance itself */ public function init(\SimpleXMLElement $node) { // set the node name + value $this->setNodeName($node->getName()); // check if we found a node value $nodeValue = (string) $node; if (empty($nodeValue) === false) { $this->setValue(trim($nodeValue)); } // load the attributes foreach ($node->attributes() as $key => $value) { $this->setData($key, (string) $value); } // append childs foreach ($node->children() as $name => $child) { // create a new configuration node $cnt = new Configuration(); // parse the configuration recursive $cnt->init($child); // append the configuration node to the parent $this->addChild($cnt); } // return the instance node itself return $this; }