diff --git a/application/src/Menu/Menu.php b/application/src/Menu/Menu.php index 6653935..ed46f6c 100644 --- a/application/src/Menu/Menu.php +++ b/application/src/Menu/Menu.php @@ -1,5 +1,4 @@ createBasicMenuItem(); - $this->dispatcher->dispatch(MenuEventType::SOURCE, new MenuEvent($this->factory, $menu, $request)); - return $menu; + return $this->createMenu(MenuEventType::SOURCE, $request); } - + public function nodeSubbar(RequestStack $request): ItemInterface { - $menu = $this->createBasicMenuItem(); - $this->dispatcher->dispatch(MenuEventType::NODE, new MenuEvent($this->factory, $menu, $request)); - return $menu; + return $this->createMenu(MenuEventType::NODE, $request); } public function userTopbar(RequestStack $request): ItemInterface { - $menu = $this->createBasicMenuItem(); - $this->dispatcher->dispatch(MenuEventType::USER, new MenuEvent($this->factory, $menu, $request)); + return $this->createMenu(MenuEventType::USER, $request); + } + + private function createMenu(string $type, RequestStack $request): ItemInterface + { + $menu = $this->createBasicMenuItem(); + $this->dispatcher->dispatch($type, new MenuEvent($this->factory, $menu, $request)); return $menu; } - - private function createBasicMenuItem():ItemInterface{ + + private function createBasicMenuItem(): ItemInterface + { return $this->factory->createItem('root', [ 'childrenAttributes' => [ - 'class' => 'navbar-nav mr-auto', - ], + 'class' => 'navbar-nav mr-auto' + ] ]); } }