/** * A helper method for building the XML tree. It appends the * node to the current node and returns the new node that should * become the new current node. * * @internal * @param Opt_Xml_Node $current The current node. * @param Opt_Xml_Node $node The newly created node. * @param Boolean $goInto Whether we visit the new node. * @return Opt_Xml_Node */ protected function _treeNodeAppend($current, $node, $goInto) { $current->appendChild($node); if ($goInto) { return $node; } return $current; }
/** * An utility method that simplifies inserting the text to the XML * tree. Depending on the last child type, it can create a new text * node or add the text to the existing one. * * @internal * @param Opt_Xml_Node $current The currently built XML node. * @param String|Opt_Xml_Node $text The text or the expression node. * @return Opt_Xml_Node The current XML node. */ protected function _treeTextAppend($current, $text) { $last = $current->getLastChild(); if (!is_object($last) || !$last instanceof Opt_Xml_Text) { if (!is_object($text)) { $node = new Opt_Xml_Text($text); } else { $node = new Opt_Xml_Text(); $node->appendChild($text); } $current->appendChild($node); } else { if (!is_object($text)) { $last->appendData($text); } else { $last->appendChild($text); } } return $current; }