Skip to content

Commit

Permalink
Throw when trying to get uninitialized menu before boot
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Feb 22, 2024
1 parent b17b7e3 commit e4957b8
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ public function registerMenu(string $name, NavigationMenu $menu): void
*/
public function getMenu(string $name): NavigationMenu
{
if (! Hyde::isBooted()) {
// Todo: This could be an anti-pattern so we may consider throwing an exception instead.
Hyde::boot();
if (! Hyde::isBooted() && ! isset($this->menus[$name])) {
throw new \Exception('Cannot get navigation menu before the Hyde Kernel is booted.');
}

return $this->menus[$name];
Expand Down

0 comments on commit e4957b8

Please sign in to comment.