From 6533acdd60b801df9ab4ca614616514fab321be7 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 27 Oct 2022 20:30:14 +0200 Subject: [PATCH] use custom app names using 'app.navigation.name' (fix #148) --- lib/Service/AppRepository.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/Service/AppRepository.php b/lib/Service/AppRepository.php index e35f65b..d507d63 100644 --- a/lib/Service/AppRepository.php +++ b/lib/Service/AppRepository.php @@ -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; }