/** * @param NodeInterface $node */ public function addChildNode(NodeInterface $node) { $node->setParent($this->getNode()); $this->childNodes[] = $node; }
/** * {@inheritdoc} */ public function add(NodeInterface $node) { $this->children[$node->hashCode()] = $node->setParent($this); return $this; }
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; }
/** * 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; }
public function appendChild(NodeInterface $node) { $node->setParent($this); $this->children->add($node); return $this; }