mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-09-02 13:21:02 +00:00
Full rewrite of the installer (incl. the finish step), self-update pipeline, settings store, cron webhook, dashboard/bootstrap surface, environment manager, wizard login, config endpoint and shared helpers. Byte-compatible public interfaces and observable behavior, including documented legacy quirks; verified by the pilot behavioral suite and the full test suite.
53 lines
1.3 KiB
PHP
53 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Platform\Operations\Http\Concerns;
|
|
|
|
/**
|
|
* Flattens a registered navigation tree into the plain arrays the SPA renders.
|
|
*/
|
|
trait GeneratesMenu
|
|
{
|
|
/**
|
|
* Read one registered menu and drop every entry this user may not see.
|
|
*
|
|
* Visibility itself is decided by the user model; this only asks.
|
|
*/
|
|
public function generateMenu($key, $user)
|
|
{
|
|
$navigation = \Menu::get($key);
|
|
|
|
if (! $navigation) {
|
|
return [];
|
|
}
|
|
|
|
$visible = [];
|
|
|
|
foreach ($navigation->items->toArray() as $entry) {
|
|
if ($user->checkAccess($entry)) {
|
|
$visible[] = $this->describeMenuEntry($entry);
|
|
}
|
|
}
|
|
|
|
return $visible;
|
|
}
|
|
|
|
/**
|
|
* One navigation entry in wire shape. Grouping label and ordering weight
|
|
* are optional in the menu definition, so they fall back here.
|
|
*/
|
|
private function describeMenuEntry(object $entry): array
|
|
{
|
|
$meta = $entry->data;
|
|
|
|
return [
|
|
'title' => $entry->title,
|
|
'link' => $entry->link->path['url'],
|
|
'icon' => $meta['icon'],
|
|
'name' => $meta['name'],
|
|
'group' => $meta['group'],
|
|
'group_label' => $meta['group_label'] ?? '',
|
|
'priority' => $meta['priority'] ?? 100,
|
|
];
|
|
}
|
|
}
|