Example #1
0
 /**
  * sort children of $node, identified by $child_id_attribute
  * this is done because the simplexml iterator can't be swap-sorted
  *
  * @param simplexmlelement   $to_node          node to sort children of
  * @param simplexmlelement   $from_node        children element name to sort
  * @param boolean            $copy_attributes  should the attributes of from_node be copied to to_node
  *
  * @return void
  */
 protected static function file_sort_children_node_merge(&$to_node, &$from_node, $copy_attributes = TRUE)
 {
     // merge 'from' attributes onto 'to' node
     if ($copy_attributes) {
         foreach ($from_node->attributes() as $attr_key => $attr_value) {
             $to_node->addAttribute($attr_key, $attr_value);
         }
     }
     foreach ($from_node->children() as $simplexml_child) {
         $simplexml_temp = $to_node->addChild($simplexml_child->getName(), self::ampersand_magic($simplexml_child));
         foreach ($simplexml_child->attributes() as $attr_key => $attr_value) {
             $simplexml_temp->addAttribute($attr_key, $attr_value);
         }
         self::file_sort_children_node_merge($simplexml_temp, $simplexml_child, FALSE);
     }
 }