blt04/doctrine2-nestedset — Issue #15: Moving methods are broken
Author: echo511
Created: 2011-11-04 11:41:51+00:00
State: open

All of the methods for moving nodes can break the nested set. For instance let's have structure like this:

LFT name RGT

1 root 6
2 section 5
3 subsection 4

If I call method **moveAsLastChildOf (section -> subsection)** it will break the hierarchy instead of throw an exception. (issued by mlueft). For this problem I have found a simple fix:

public function moveAsLastChildOf(NodeWrapper $node)
{
// Added ancestor check
if($this->isAncestorOf($node) || $this == $node)
{
throw new \InvalidArgumentException('Cannot move node as a child of itself');
}
...

Same for moveAsFirstChildOf().

The siblings methods however are more complicated especially **moveAsPrevSiblingOf(subsection->section)** which should be possible to do.

Any solutions?