use custom app names using 'app.navigation.name' (fix #148)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Simon Vieille 2022-10-27 20:30:14 +02:00
parent f20dc7282e
commit 6533acdd60
Signed by: deblan
GPG key ID: 579388D585F70417

View file

@ -36,8 +36,7 @@ class AppRepository
IFactory $l10nFactory,
ConfigProxy $config,
CategoryRepository $categoryRepository
)
{
) {
$this->ocApp = $ocApp;
$this->l10nFactory = $l10nFactory;
$this->config = $config;
@ -62,7 +61,7 @@ class AppRepository
foreach ([$app['id'], $app['id'].'_index'] as $id) {
if (isset($navigation[$id])) {
$app['name'] = $this->l10nFactory->get($id)->t($app['name']);
$app['name'] = $this->getAppName($app);
$app['href'] = $navigation[$id]['href'];
$app['icon'] = $navigation[$id]['icon'];
@ -75,7 +74,7 @@ class AppRepository
if ('external_index' === substr($app['id'], 0, 14)) {
$visibleApps[$app['id']] = [
'id' => $app['id'],
'name' => $this->l10nFactory->get($app['id'])->t($app['name']),
'name' => $this->getAppName($app),
'href' => $app['href'],
'icon' => $app['icon'],
'category' => [
@ -85,7 +84,7 @@ class AppRepository
} elseif ('files' === $app['id']) {
$visibleApps[$app['id']] = [
'id' => $app['id'],
'name' => $this->l10nFactory->get($app['id'])->t($app['name']),
'name' => $this->getAppName($app),
'href' => $app['href'],
'icon' => $app['icon'],
'category' => [],
@ -106,6 +105,15 @@ class AppRepository
return $visibleApps;
}
public function getAppName($app)
{
return $this->config->getAppValue(
'app.navigation.name',
$this->l10nFactory->get($app['id'])->t($app['name']),
$app['id']
);
}
public function getTopMenuOrderedApps()
{
$apps = $this->getVisibleApps();
@ -115,7 +123,7 @@ class AppRepository
$ak = array_keys($orders, $a['id'])[0] ?? null;
$bk = array_keys($orders, $b['id'])[0] ?? null;
if ($ak === null || $bk === null) {
if (null === $ak || null === $bk) {
return ($a['name'] < $b['name']) ? -1 : 1;
}