creocoder / yii2-nested-sets

The nested sets behavior for the Yii framework.
Other
446 stars 129 forks source link

Multiroot feature has gone away? #41

Closed ptheofan closed 9 years ago

ptheofan commented 9 years ago

Did the multiroot functionality go away with the latest update? The hasManyRoots attribute is no longer supported.

ptheofan commented 9 years ago

Ok, it appears the hasManyRoots has been substituted with the treeAttribute. To transparently upgrade from the older version use it like this

    /**
     * @return array
     */
    public function behaviors() {
        return [
            [
                'class' => NestedSetsBehavior::className(),
                'treeAttribute' => 'root',
                'depthAttribute' => 'level',
            ],
        ];
    }
Mihai-P commented 9 years ago

It has not gone away, but it is not working properly from my tests, the lft rgt attributes are wrong. I am looking now to fix it.

ptheofan commented 9 years ago

hm, ok, let me know if I can help in any way.

creocoder commented 9 years ago

This is already fixed.

creocoder commented 9 years ago

@ptheofan Btw you can't transparently upgrade from old versions because Yii 1 version is not old version, it just different version. And this behavior is not released. You can look at milestones when release come. For example instead of level another depth attribute is introduced. It starts from 0 instead of 1. Also there will be changes to root's attributes. So i can't recommend upgrade schemas for now. Probably converter will be needed. For example $depthAttribute will be optional, because not all NS tasks need it.