cakephp/cakephp — pull request #444 by thomseddon (2012-01-26 23:21:23+00:00)
Title: Multi Tree support for scoped Tree Behaviour

Although the current Tree Behaviour does support a scopped tree to some extent, all records reside in a single MPTT tree, which can result in poor write/remove performance on a large tree, especially when modifying towards the top of the tree.

I have extended the scope support so that by enabling an additional option, "multiTree => true", an individual tree will revolve around the desired "belongsTo" key, so for example each user could have their own tree!
This will go a long way to increasing write performance for the overall model.
There are a fair few examples across the internet, but I have built this on the latest branch and tried to conform to cake standards...

All current test pass, and I have included a pretty comprehensive set of tests copied from the existing "number" set for the Tree Behaviour, most of them just prove/ensure that the scope is adhered to correctly.

I suppose these could be some discussion about if this is the best way to include this kind of support, I considered a separate behaviour "ForestBehavior", but figured it would just end up mainly a rewrite?

Anyway, would love to hear your thoughts and advice!

Thom