diff --git a/lib/private/NavigationManager.php b/lib/private/NavigationManager.php index 28d13a4a311f3..80f8b6311879b 100644 --- a/lib/private/NavigationManager.php +++ b/lib/private/NavigationManager.php @@ -70,7 +70,7 @@ public function add($entry) { $this->closureEntries[] = $entry; return; } - $this->init(); + $this->init(false); $id = $entry['id']; @@ -106,10 +106,6 @@ public function add($entry) { */ 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') { @@ -195,7 +191,13 @@ public function getActiveEntry() { 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; }