Example #1
0
 /**
  * @param NodeInterface $node
  */
 public function addChildNode(NodeInterface $node)
 {
     $node->setParent($this->getNode());
     $this->childNodes[] = $node;
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function add(NodeInterface $node)
 {
     $this->children[$node->hashCode()] = $node->setParent($this);
     return $this;
 }
Example #3
0
 public function replaceChild($key, NodeInterface $node)
 {
     if (!isset($this->children[$key])) {
         throw new \InvalidArgumentException(sprintf("%s child does not exist", $key));
     }
     $node->setParent($this);
     $this->children[$key] = $node;
 }
Example #4
0
 /**
  * Set child
  *
  * @param int $position
  * @param NodeInterface|null $child
  * @return $this
  */
 public function setChild($position, NodeInterface $child = null)
 {
     $this->children[$position] = $child;
     if (null !== $child) {
         $child->setParent($this)->setPosition($position);
     }
     return $this;
 }
Example #5
0
 public function appendChild(NodeInterface $node)
 {
     $node->setParent($this);
     $this->children->add($node);
     return $this;
 }