Search code examples
doctrine-ormnested-sets

How to move treenodes with Gedmo's NestedSet Behaviour


i'm using Doctrine 2 and the NestedSet extension. In Doctrine 1 you had the functions moveAsPrevSiblingOf, moveAsNextSiblingOf and moveAsLastChildOf To move nodes around.

In the documentation of the nested extension only moving a node within the same parent is explained. Move a node to another node is not mention. How can this be done?

Are there easy to use functions as found in Doctrine 1 available?


Solution

  • In the documentation there are examples on how to move the nodes.

    $treeRepository
        ->persistAsFirstChild($food)
        ->persistAsFirstChildOf($fruits, $food)
        ->persistAsLastChildOf($vegitables, $food)
        ->persistAsNextSiblingOf($carrots, $fruits);