public function makeChildOf(Node $node, Node $newParent) { // The node is already a child of newParent if ($node->__get($this->parentCol()) == $newParent->__get($this->pkCol()) && $node->exists) { return $this; } $node->__set($this->parentCol(), $newParent->__get($this->pkCol())); $node->__set($this->rootCol(), $newParent->__get($this->rootCol())); $node->setParentNode($newParent); $newParent->addChildNode($node); $node->save(); return $this; }
/** * @brief Adds a childNode to this node * * @return NodeInterface */ public function addChildNode(NodeInterface $childNode) { $this->childNodes[] = $childNode; $childNode->setParentNode($this); return $this; }