| @@ 203-217 (lines=15) @@ | ||
| 200 | * @param callable $childCallback Optional callback. |
|
| 201 | * @return MenuItemInterface[] |
|
| 202 | */ |
|
| 203 | public function children(callable $childCallback = null) |
|
| 204 | { |
|
| 205 | $children = $this->children; |
|
| 206 | uasort($children, ['self', 'sortChildrenByPrioriy']); |
|
| 207 | ||
| 208 | $childCallback = isset($childCallback) ? $childCallback : $this->childCallback; |
|
| 209 | foreach ($children as $child) { |
|
| 210 | if ($childCallback) { |
|
| 211 | $childCallback($child); |
|
| 212 | } |
|
| 213 | $GLOBALS['widget_template'] = $item->template(); |
|
| 214 | yield $child->ident() => $child; |
|
| 215 | $GLOBALS['widget_template'] = ''; |
|
| 216 | } |
|
| 217 | } |
|
| 218 | ||
| 219 | /** |
|
| 220 | * @return boolean |
|
| @@ 124-138 (lines=15) @@ | ||
| 121 | * @param callable $itemCallback Optional. Item callback. |
|
| 122 | * @return MenuItemInterface[] |
|
| 123 | */ |
|
| 124 | public function items(callable $itemCallback = null) |
|
| 125 | { |
|
| 126 | $items = $this->items; |
|
| 127 | uasort($items, [$this, 'sortItemsByPriority']); |
|
| 128 | ||
| 129 | $itemCallback = isset($itemCallback) ? $itemCallback : $this->itemCallback; |
|
| 130 | foreach ($items as $item) { |
|
| 131 | if ($itemCallback) { |
|
| 132 | $itemCallback($item); |
|
| 133 | } |
|
| 134 | $GLOBALS['widget_template'] = $item->template(); |
|
| 135 | yield $item->ident() => $item; |
|
| 136 | $GLOBALS['widget_template'] = ''; |
|
| 137 | } |
|
| 138 | } |
|
| 139 | ||
| 140 | /** |
|
| 141 | * @return boolean |
|