/** * Check if this node can be moved under another parent. * * @param Node $newParent The new parent node. * * @return MoveException|null Return a MoveException in case of problems, null in case of success. */ public function checkMove(Node $newParent) { $result = null; if ($this->getTreeNodeParentID() != $newParent->getTreeNodeID()) { if ($this->getTreeNodeID() == $newParent->getTreeNodeID()) { $result = new MoveException(t("It's not possible to move a node under itself")); } else { foreach ($newParent->getTreeNodeParentArray() as $newParentAncestor) { if ($newParentAncestor->getTreeNodeID() == $this->getTreeNodeID()) { $result = MoveException(t("It's not possible to move a node under one of its descending nodes")); break; } } } } return $result; }