diff options
Diffstat (limited to 'lib/private/NavigationManager.php')
-rw-r--r-- | lib/private/NavigationManager.php | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/lib/private/NavigationManager.php b/lib/private/NavigationManager.php index 4bcd78b7fcf..fb0795376bb 100644 --- a/lib/private/NavigationManager.php +++ b/lib/private/NavigationManager.php @@ -77,7 +77,7 @@ class NavigationManager implements INavigationManager { $this->closureEntries[] = $entry; return; } - $this->init(); + $this->init(false); $id = $entry['id']; @@ -110,9 +110,10 @@ class NavigationManager implements INavigationManager { } private function updateDefaultEntries() { + $defaultEntryId = $this->getDefaultEntryIdForUser($this->userSession->getUser(), false); foreach ($this->entries as $id => $entry) { if ($entry['type'] === 'link') { - $this->entries[$id]['default'] = $id === $this->getDefaultEntryIdForUser($this->userSession->getUser(), false); + $this->entries[$id]['default'] = $id === $defaultEntryId; } } } @@ -122,10 +123,6 @@ class NavigationManager implements INavigationManager { */ public function getAll(string $type = 'link'): array { $this->init(); - foreach ($this->closureEntries as $c) { - $this->add($c()); - } - $this->closureEntries = []; $result = $this->entries; if ($type !== 'all') { @@ -211,7 +208,13 @@ class NavigationManager implements INavigationManager { return $this->activeEntry; } - private function init() { + private function init(bool $resolveClosures = true): void { + if ($resolveClosures) { + while ($c = array_pop($this->closureEntries)) { + $this->add($c()); + } + } + if ($this->init) { return; } @@ -328,7 +331,7 @@ class NavigationManager implements INavigationManager { $apps = $this->appManager->getEnabledAppsForUser($user); $this->customAppOrder = json_decode($this->config->getUserValue($user->getUID(), 'core', 'apporder', '[]'), true, flags:JSON_THROW_ON_ERROR); } else { - $apps = $this->appManager->getInstalledApps(); + $apps = $this->appManager->getEnabledApps(); $this->customAppOrder = []; } @@ -419,11 +422,6 @@ class NavigationManager implements INavigationManager { public function get(string $id): ?array { $this->init(); - foreach ($this->closureEntries as $c) { - $this->add($c()); - } - $this->closureEntries = []; - return $this->entries[$id]; } |