forked from deblan/side_menu
add custom apps sorting
This commit is contained in:
parent
7d82c78581
commit
84c620637e
8 changed files with 85 additions and 1 deletions
|
|
@ -105,4 +105,23 @@ class AppRepository
|
|||
|
||||
return $visibleApps;
|
||||
}
|
||||
|
||||
public function getTopMenuOrderedApps()
|
||||
{
|
||||
$apps = $this->getVisibleApps();
|
||||
$orders = $this->config->getAppValueArray('top-menu-apps-order', '[]');
|
||||
|
||||
usort($apps, function ($a, $b) use ($orders) {
|
||||
$ak = array_keys($orders, $a['id'])[0] ?? null;
|
||||
$bk = array_keys($orders, $b['id'])[0] ?? null;
|
||||
|
||||
if ($ak === null || $bk === null) {
|
||||
return ($a['name'] < $b['name']) ? -1 : 1;
|
||||
}
|
||||
|
||||
return $ak < $bk ? -1 : 1;
|
||||
});
|
||||
|
||||
return $apps;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue