KnpLabs/KnpMenu — Issue #32: Removing the getCurrentItem method
Author: stof
Created: 2012-02-12 19:08:19+00:00
State: open
Labels: RFC

I open this issue to separate the discussion about this point as I originally asked in #2 but it got a bit lost in the other part of the issue.

As mentioned previously in #2, this method is currently lying as it returns the first current item found whereas the tree could contain several item.
So I see 3 solutions:

1. **Forbid to have more than 1 current item.** This would be quite hard to do in an efficient way and most people commenting on it previously thought it is valid to have several one.
2. **Remove the method**
3. **Replace the method by a ``getCurrentItems`` method.** This method would return an array containing all current items inside the tree of the item.

I personally think that the third option is not necessary. Implementing it using some PHP iterators would be probably more efficient as we would loop over the whole tree only when actually looping over the data instead of doing it first to create the array (and for people wanting an array absolutely, they could still use ``iterator_to_array``).

So my personal vote would be 2