public function setRightChild(TreeNode $childNode)
 {
     $this->rightChild = $childNode;
     $childNode->setParent($this);
 }
Example #2
0
 /**
  * Adds a child TreeNode to the current node.
  * Note that this sets the parent of the item
  * as well.
  *
  * @access public
  * @param TreeNode $item
  * @return TreeNode the treenode passed in
  */
 public function addChild(TreeNode &$item)
 {
     $item->setParent($this);
     array_push($this->children, $item);
     return $item;
 }
Example #3
0
 /**
  * Add a child node to the current node.
  *
  * Notifies the child of its parent and adds the child name to
  * the child name array. Does not enforce unique names since it
  * may be desireable to have non-unique named children. It's on
  * the developer to not rely on the get() method in that case
  *
  * @return void
  */
 public function add(TreeNode $child)
 {
     if ($child == $this) {
         throw new \RuntimeException('Cannot add tree node to itself.');
     }
     if ($this->_frozen) {
         throw new \RuntimeException('Cannot add child. Tree node is frozen.');
     }
     $this->children[] = $child;
     $this->children_names[$child->name] = $child;
     $child->setParent($this);
 }