| @@ 122-135 (lines=14) @@ | ||
| 119 | * |
|
| 120 | * @return $this |
|
| 121 | */ |
|
| 122 | public function each(callable $callable) |
|
| 123 | { |
|
| 124 | $type = $this->determineFirstParameterType($callable); |
|
| 125 | ||
| 126 | foreach ($this->items as $item) { |
|
| 127 | if ($type !== null && !$item instanceof $type) { |
|
| 128 | continue; |
|
| 129 | } |
|
| 130 | ||
| 131 | $callable($item); |
|
| 132 | } |
|
| 133 | ||
| 134 | return $this; |
|
| 135 | } |
|
| 136 | ||
| 137 | /** |
|
| 138 | * Register a filter to the menu. When an item is added, all filters will be applied to the |
|
| @@ 255-270 (lines=16) @@ | ||
| 252 | * |
|
| 253 | * @return $this |
|
| 254 | */ |
|
| 255 | public function setActive(callable $callable) |
|
| 256 | { |
|
| 257 | $type = $this->determineFirstParameterType($callable); |
|
| 258 | ||
| 259 | foreach ($this->items as $item) { |
|
| 260 | if ($type && !$item instanceof $type) { |
|
| 261 | continue; |
|
| 262 | } |
|
| 263 | ||
| 264 | if ($callable($item)) { |
|
| 265 | $item->setActive(); |
|
| 266 | } |
|
| 267 | } |
|
| 268 | ||
| 269 | return $this; |
|
| 270 | } |
|
| 271 | ||
| 272 | /** |
|
| 273 | * Render the menu in html. |
|