diff --git a/application/config/services.yaml b/application/config/services.yaml index c5c9ecb..f0bf69b 100644 --- a/application/config/services.yaml +++ b/application/config/services.yaml @@ -26,6 +26,11 @@ services: factory: ['@app.menu_builder', 'sourceNavbar'] tags: - { name: knp_menu.menu, alias: sourceNavbar } + app.menu.node: + class: Knp\Menu\MenuItem + factory: ['@app.menu_builder', 'nodeSubbar'] + tags: + - { name: knp_menu.menu, alias: nodeSubbar } # makes classes in src/ available to be used as services # this creates a service per class whose id is the fully-qualified class name App\: diff --git a/application/src/DBAL/Types/MenuEventType.php b/application/src/DBAL/Types/MenuEventType.php index 86a5991..7569131 100644 --- a/application/src/DBAL/Types/MenuEventType.php +++ b/application/src/DBAL/Types/MenuEventType.php @@ -13,10 +13,13 @@ final class MenuEventType extends AbstractEnumType { public const USER = 'app.menu.topbar.user'; - public const SOURCE = 'app.menu.source.user'; + public const SOURCE = 'app.menu.subbar.source'; - protected static $choices = [ - self::USER => self::USER, - self::SOURCE => self::SOURCE, - ]; + public const NODE = 'app.menu.subbar.node'; + + /** + * May this will be used in the future + * @var array + */ + protected static $choices = []; } diff --git a/application/src/Menu/Menu.php b/application/src/Menu/Menu.php index 6a9c3e7..6653935 100644 --- a/application/src/Menu/Menu.php +++ b/application/src/Menu/Menu.php @@ -27,29 +27,32 @@ class Menu $this->factory = $factory; } - public function SourceNavbar(RequestStack $request): ItemInterface + public function sourceNavbar(RequestStack $request): ItemInterface { - $menu = $this->factory->createItem('root', [ - 'childrenAttributes' => [ - 'class' => 'navbar-nav mr-auto', - ], - ]); - + $menu = $this->createBasicMenuItem(); $this->dispatcher->dispatch(MenuEventType::SOURCE, new MenuEvent($this->factory, $menu, $request)); - + return $menu; + } + + public function nodeSubbar(RequestStack $request): ItemInterface + { + $menu = $this->createBasicMenuItem(); + $this->dispatcher->dispatch(MenuEventType::NODE, new MenuEvent($this->factory, $menu, $request)); return $menu; } public function userTopbar(RequestStack $request): ItemInterface { - $menu = $this->factory->createItem('root', [ + $menu = $this->createBasicMenuItem(); + $this->dispatcher->dispatch(MenuEventType::USER, new MenuEvent($this->factory, $menu, $request)); + return $menu; + } + + private function createBasicMenuItem():ItemInterface{ + return $this->factory->createItem('root', [ 'childrenAttributes' => [ 'class' => 'navbar-nav mr-auto', ], ]); - - $this->dispatcher->dispatch(MenuEventType::USER, new MenuEvent($this->factory, $menu, $request)); - - return $menu; } } diff --git a/application/src/Subscriber/NodeMenuSubscriber.php b/application/src/Subscriber/NodeMenuSubscriber.php index fb1dc67..27c7c94 100644 --- a/application/src/Subscriber/NodeMenuSubscriber.php +++ b/application/src/Subscriber/NodeMenuSubscriber.php @@ -1,6 +1,8 @@ 'onNodeMenuConfigure' ]; } }