Baum\SetBuilder::rebuild PHP Method

rebuild() public method

Perform the re-calculation of the left and right indexes of the whole nested set tree structure.
public rebuild ( ) : void
return void
    public function rebuild()
    {
        // Rebuild lefts and rights for each root node and its children (recursively).
        // We go by setting left (and keep track of the current left bound), then
        // search for each children and recursively set the left index (while
        // incrementing that index). When going back up the recursive chain we start
        // setting the right indexes and saving the nodes...
        $self = $this;
        $this->node->getConnection()->transaction(function () use($self) {
            foreach ($self->roots() as $root) {
                $self->rebuildBounds($root, 0);
            }
        });
    }

Usage Example

Example #1
0
 /**
  * Rebuilds the structure of the current Nested Set.
  *
  * @param  bool $force
  *
  * @return void
  */
 public static function rebuild($force = false)
 {
     $builder = new SetBuilder(new static());
     $builder->rebuild($force);
 }
All Usage Examples Of Baum\SetBuilder::rebuild