Phalcon\Mvc\Model\Behavior\NestedSet::makeRoot PHP Method

makeRoot() private method

private makeRoot ( array $attributes, array $whiteList ) : boolean
$attributes array
$whiteList array
return boolean
    private function makeRoot($attributes, $whiteList)
    {
        $owner = $this->getOwner();
        $owner->{$this->rootAttribute} = 0;
        $owner->{$this->leftAttribute} = 1;
        $owner->{$this->rightAttribute} = 2;
        $owner->{$this->levelAttribute} = 1;
        if ($this->hasManyRoots) {
            $this->db->begin();
            $this->ignoreEvent = true;
            if ($owner->create($attributes, $whiteList) == false) {
                $this->db->rollback();
                $this->ignoreEvent = false;
                return false;
            }
            $pk = $owner->{$this->rootAttribute} = $owner->{$this->primaryKey};
            $owner::findFirst($pk)->update([$this->rootAttribute => $pk]);
            $this->ignoreEvent = false;
            $this->db->commit();
        } else {
            if (count($owner->roots())) {
                throw new Exception('Cannot create more than one root in single root mode.');
            }
            if ($owner->create($attributes, $whiteList) == false) {
                return false;
            }
        }
        return true;
    }