FOF30\Model\TreeModel::moveLeft PHP Method

moveLeft() public method

Move the current node (and its subtree) one position to the left in the tree, i.e. before its left-hand sibling
public moveLeft ( )
    public function moveLeft()
    {
        // Sanity checks on current node position
        if ($this->lft >= $this->rgt) {
            throw new TreeInvalidLftRgtCurrent();
        }
        // If it is a root node we will not move the node (roots don't participate in tree ordering)
        if ($this->isRoot()) {
            return $this;
        }
        // Are we already the leftmost node?
        $parentNode = $this->getParent();
        if ($parentNode->lft == $this->lft - 1) {
            return $this;
        }
        // Get the sibling to the left
        $db = $this->getDbo();
        $leftSibling = $this->getClone()->reset()->whereRaw($db->qn($this->getFieldAlias('rgt')) . ' = ' . $db->q($this->lft - 1))->firstOrFail();
        // Move the node
        return $this->moveToLeftOf($leftSibling);
    }