src/Franzose/ClosureTable/Models/Entity.php
protected function setupReordering($parentIdChanged)
    {
        $range = $action = null;
        // If the model's parent was changed, firstly we decrement
        // positions of the 'old' next siblings of the model.
        if ($parentIdChanged === true) {
            $range = $this->old_position;
            $action = 'decrement';
        } else {
            // TODO: There's probably a bug here where if you just created an entity and you set it to be
            // a root (parent_id = null) then it comes in here (while it should have gone in the else)
            // Reordering within the same ancestor
            if ($this->old_parent_id !== false && $this->old_parent_id == $this->parent_id) {
                if ($this->position > $this->old_position) {
                    $range = [$this->old_position, $this->position];
                    $action = 'decrement';
                } else if ($this->position < $this->old_position) {
                    $range = [$this->position, $this->old_position];
                    $action = 'increment';
                }
            } // Ancestor has changed
            else {
                $range = $this->position;
                $action = 'increment';
            }
        }

        if (!is_array($range)) {
            $range = [$range, null];
        }

        return [$range, $action];
    }
protected function setupReordering($parentIdChanged)
    {
        $range = $action = null;
        // If the model's parent was changed, firstly we decrement
        // positions of the 'old' next siblings of the model.
        if ($parentIdChanged === true) {
            $range = $this->old_position;
            $action = 'decrement';
        } else {
            // TODO: There's probably a bug here where if you just created an entity and you set it to be
            // a root (parent_id = null) then it comes in here (while it should have gone in the else)
            // Reordering within the same ancestor
            if ($this->old_parent_id !== false && $this->old_parent_id == $this->parent_id) {
                if ($this->position > $this->old_position) {
                    $range = [$this->old_position, $this->position];
                    $action = 'decrement';
                } else if ($this->position < $this->old_position) {
                    $range = [$this->position, $this->old_position];
                    $action = 'increment';
                }
            } // Ancestor has changed
            else {
                $range = $this->position;
                $action = 'increment';
            }
        }

        if (!is_array($range)) {
            $range = [$range, null];
        }

        return [$range, $action];
    }
protected function setupReordering ( $ parentIdChanged ) { $ range = $ action = null ; // If the model's parent was changed, firstly we decrement // positions of the 'old' next siblings of the model. if ( $ parentIdChanged === true ) { $ range = $ this -> old_position ; $ action = 'decrement' ; } else { // TODO: There's probably a bug here where if you just created an entity and you set it to be // a root (parent_id = null) then it comes in here (while it should have gone in the else) // Reordering within the same ancestor if ( $ this -> old_parent_id !== false && $ this -> old_parent_id == $ this -> parent_id ) { if ( $ this -> position > $ this -> old_position ) { $ range = [ $ this -> old_position , $ this -> position ] ; $ action = 'decrement' ; } else if ( $ this -> position < $ this -> old_position ) { $ range = [ $ this -> position , $ this -> old_position ] ; $ action = 'increment' ; } } // Ancestor has changed else { $ range = $ this -> position ; $ action = 'increment' ; } } if ( ! is_array ( $ range ) ) { $ range = [ $ range , null ] ; } return [ $ range , $ action ] ; }
Setups model's siblings reordering.

Actually, the method determines siblings that will be reordered
by creating range of theirs positions and determining the action
that will be used in reordering ('increment' or 'decrement').

@param bool $parentIdChanged
@return array
Setups model s siblings reordering .