Nested Set Behavior 2 Preview Version For Yii 2 Preview Version

This is new version of my https://github.com/yiiext/nested-set-behavior

I really hope for feedback.

Did you basically adjust it to yii2’s new ActiveRecords, or are there any new concepts?

One thing I didn’t like about the original version (although I think it was the only option you had) was the use of a special save() method. I think it’s kind of weird that you work with an AR, attach an behavior to it, and all of a sudden can’t use its original methods any more. If the new AR design allows to change this, I think it would be a great improvement.

Other nice to have’s:

  • possibility to store the tree structure in a separate db table. Maybe really one structure table, for data from n other tables (but that would mean to loose FK constraint support).

  • there are a few advanced nested set numbering methods available, I think mostly targeting the speed-up of structure changes. The basic method with lft, rgt running from 1 to n*2 when using n data sets has the disadvantage that you need to renumber large portions of the available datasets when changing the tree structure. Other methods try to use ranges, leaving space between lft and rgt for future insertions so you don’t have to renumber on every write. Or they use floats instead of integers so that you can always insert a new element (insert between 1 and 2 --> use 1/2. Insert between 1/2 and 1 --> 1/4).

All new ActiveRecord concepts used.

New AR design can’t allow this. This is php limitation.

You can do that with existing behavior.

Better to use another tree type. This is NS confines.

@creocoder: this is great. Could you summarize your feeling about the new AR design on the aspect of developing behaviors, compared with that in 1.1? I’d like to hear this feedback to see if we miss anything.

@qiang: Thanks. I need to investigate a little more. After that i’ll say my opinion.

[color="#006400"]/* extension authoring guidelines discussion split out into this topic: http://www.yiiframework.com/forum/index.php/topic/43047-guidelines-for-extension-authoring/ */[/color]

Hello.

Very nice extension. I want to ask, maybe you are going to add functionality of moving subtree to another node as parent?

I got 3000+ records in my tree and when one parent node is removed, I want easily move all its children to new parent.