source/Application/Controller/Admin/NavigationTree.php
protected function _mergeNodes($domElemTo, $domElemFrom, $xPathTo, $domDocTo, $queryStart)
    {
        foreach ($domElemFrom->childNodes as $fromNode) {
            if ($fromNode->nodeType === XML_ELEMENT_NODE) {
                $fromAttrName = $fromNode->getAttribute('id');
                $fromNodeName = $fromNode->tagName;

                // find current item
                $query = "{$queryStart}/{$fromNodeName}[@id='{$fromAttrName}']";
                $curNode = $xPathTo->query($query);

                // if not found - append
                if ($curNode->length == 0) {
                    $domElemTo->appendChild($domDocTo->importNode($fromNode, true));
                } else {
                    $curNode = $curNode->item(0);

                    // if found copy all attributes and check childnodes
                    $this->_copyAttributes($curNode, $fromNode);

                    if ($fromNode->childNodes->length) {
                        $this->_mergeNodes($curNode, $fromNode, $xPathTo, $domDocTo, $query);
                    }
                }
            }
        }
    }
protected function _mergeNodes($domElemTo, $domElemFrom, $xPathTo, $domDocTo, $queryStart)
    {
        foreach ($domElemFrom->childNodes as $fromNode) {
            if ($fromNode->nodeType === XML_ELEMENT_NODE) {
                $fromAttrName = $fromNode->getAttribute('id');
                $fromNodeName = $fromNode->tagName;

                // find current item
                $query = "{$queryStart}/{$fromNodeName}[@id='{$fromAttrName}']";
                $curNode = $xPathTo->query($query);

                // if not found - append
                if ($curNode->length == 0) {
                    $domElemTo->appendChild($domDocTo->importNode($fromNode, true));
                } else {
                    $curNode = $curNode->item(0);

                    // if found copy all attributes and check childnodes
                    $this->_copyAttributes($curNode, $fromNode);

                    if ($fromNode->childNodes->length) {
                        $this->_mergeNodes($curNode, $fromNode, $xPathTo, $domDocTo, $query);
                    }
                }
            }
        }
    }
protected function _mergeNodes ( $ domElemTo , $ domElemFrom , $ xPathTo , $ domDocTo , $ queryStart ) { foreach ( $ domElemFrom -> childNodes as $ fromNode ) { if ( $ fromNode -> nodeType === XML_ELEMENT_NODE ) { $ fromAttrName = $ fromNode -> getAttribute ( 'id' ) ; $ fromNodeName = $ fromNode -> tagName ; // find current item $ query = "{$queryStart}/{$fromNodeName}[@id='{$fromAttrName}']" ; $ curNode = $ xPathTo -> query ( $ query ) ; // if not found - append if ( $ curNode -> length == 0 ) { $ domElemTo -> appendChild ( $ domDocTo -> importNode ( $ fromNode , true ) ) ; } else { $ curNode = $ curNode -> item ( 0 ) ; // if found copy all attributes and check childnodes $ this -> _copyAttributes ( $ curNode , $ fromNode ) ; if ( $ fromNode -> childNodes -> length ) { $ this -> _mergeNodes ( $ curNode , $ fromNode , $ xPathTo , $ domDocTo , $ query ) ; } } } } }
Merges nodes of newly added menu xml file

@param object $domElemTo   merge target
@param object $domElemFrom merge source
@param object $xPathTo     node path
@param object $domDocTo    node to append child
@param string $queryStart  node query
Merges nodes of newly added menu xml file