dispatcher = $dispatcher; $this->factory = $factory; } public function sourceNavbar(RequestStack $request): ItemInterface { return $this->createMenu(MenuEventType::SOURCE, $request); } public function nodeSubbar(RequestStack $request): ItemInterface { return $this->createMenu(MenuEventType::NODE, $request); } public function userTopbar(RequestStack $request): ItemInterface { 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 { return $this->factory->createItem('root', [ 'childrenAttributes' => [ 'class' => 'navbar-nav mr-auto', ], ]); } }