Skip to content

Commit c09d071

Browse files
committed
Add user menu items in SharpMenuManager::getFlattenedItems()
1 parent 362f7c3 commit c09d071

1 file changed

Lines changed: 10 additions & 16 deletions

File tree

src/Utils/Menu/SharpMenuManager.php

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,33 +26,27 @@ public function getItems(): Collection
2626
{
2727
return $this->menu()
2828
?->items()
29-
->filter(function (SharpMenuItem $item) {
30-
if ($item->isSection()) {
31-
return count($this->resolveSectionItems($item)) > 0;
32-
}
33-
34-
return $item->isAllowed();
35-
}) ?? collect();
29+
->filter(fn (SharpMenuItem $item) => $item->isSection()
30+
? count($this->resolveSectionItems($item)) > 0
31+
: $item->isAllowed()
32+
) ?? collect();
3633
}
3734

3835
public function getFlattenedItems(): Collection
3936
{
4037
return $this->getItems()
41-
->map(function (SharpMenuItem $item) {
42-
return $item->isSection()
43-
? $this->resolveSectionItems($item)
44-
: $item;
45-
})
38+
->map(fn (SharpMenuItem $item) => $item->isSection()
39+
? $this->resolveSectionItems($item)
40+
: $item
41+
)
42+
->merge($this->userMenu()?->getItems() ?? collect())
4643
->flatten();
4744
}
4845

4946
public function getEntityMenuItem(string $entityKey): ?SharpMenuItemLink
5047
{
5148
return $this->getFlattenedItems()
52-
->first(function (SharpMenuItem $item) use ($entityKey) {
53-
return $item->isEntity()
54-
&& $item->getEntityKey() === $entityKey;
55-
});
49+
->first(fn (SharpMenuItem $item) => $item->isEntity() && $item->getEntityKey() === $entityKey);
5650
}
5751

5852
public function resolveSectionItems(SharpMenuItemSection $section): Collection

0 commit comments

Comments
 (0)