Exemple #1
0
 public function add_child($father_node, ApmTree $to_add, $as_first_child = false)
 {
     if ($father_node === false || $father_node === '' || $father_node === null) {
         //$father_node can be 0!
         $father_node = $this->get_root();
     }
     if (array_key_exists($father_node, $this->tree)) {
         if ($as_first_child) {
             array_unshift($this->tree[$father_node], $to_add->get_root());
         } else {
             $this->tree[$father_node][] = $to_add->get_root();
         }
     } else {
         $this->tree = $this->tree + array($father_node => array($to_add->get_root()));
     }
     if (!$to_add->is_simple_node()) {
         $this->tree = $this->tree + $to_add->get_tree();
     }
 }