diff --git a/application/src/DBAL/Types/MenuEventType.php b/application/src/DBAL/Types/MenuEventType.php new file mode 100644 index 0000000..86a5991 --- /dev/null +++ b/application/src/DBAL/Types/MenuEventType.php @@ -0,0 +1,22 @@ + self::USER, + self::SOURCE => self::SOURCE, + ]; +} diff --git a/application/src/Event/Menu/AbstractMenuEvent.php b/application/src/Event/Menu/MenuEvent.php similarity index 95% rename from application/src/Event/Menu/AbstractMenuEvent.php rename to application/src/Event/Menu/MenuEvent.php index 8cee78a..59ff717 100644 --- a/application/src/Event/Menu/AbstractMenuEvent.php +++ b/application/src/Event/Menu/MenuEvent.php @@ -11,7 +11,7 @@ use Symfony\Component\HttpFoundation\RequestStack; * @author kevinfrantz * */ -abstract class AbstractMenuEvent extends Event +class MenuEvent extends Event { /** * @var FactoryInterface diff --git a/application/src/Event/Menu/Subbar/SourceMenuEvent.php b/application/src/Event/Menu/Subbar/SourceMenuEvent.php deleted file mode 100644 index 5a99ba0..0000000 --- a/application/src/Event/Menu/Subbar/SourceMenuEvent.php +++ /dev/null @@ -1,10 +0,0 @@ -dispatcher->dispatch(SourceMenuEvent::EVENT, new SourceMenuEvent($this->factory, $menu, $request)); + $this->dispatcher->dispatch(MenuEventType::SOURCE, new MenuEvent($this->factory, $menu, $request)); return $menu; } @@ -48,7 +48,7 @@ class Menu ], ]); - $this->dispatcher->dispatch(UserMenuEvent::EVENT, new UserMenuEvent($this->factory, $menu, $request)); + $this->dispatcher->dispatch(MenuEventType::USER, new MenuEvent($this->factory, $menu, $request)); return $menu; } diff --git a/application/src/Subscriber/SourceMenuSubscriber.php b/application/src/Subscriber/SourceMenuSubscriber.php index 22a03a7..6d7b4a1 100644 --- a/application/src/Subscriber/SourceMenuSubscriber.php +++ b/application/src/Subscriber/SourceMenuSubscriber.php @@ -2,11 +2,12 @@ namespace App\Subscriber; -use App\Event\Menu\Subbar\SourceMenuEvent; +use App\Event\Menu\MenuEvent; +use App\DBAL\Types\MenuEventType; class SourceMenuSubscriber extends AbstractEntityMenuSubscriber { - public function onSourceMenuConfigure(SourceMenuEvent $event): void + public function onSourceMenuConfigure(MenuEvent $event): void { $menu = $event->getItem(); $menu->addChild($this->translator->trans('edit'), [ @@ -33,7 +34,7 @@ class SourceMenuSubscriber extends AbstractEntityMenuSubscriber public static function getSubscribedEvents(): array { return [ - SourceMenuEvent::EVENT => 'onSourceMenuConfigure', + MenuEventType::SOURCE => 'onSourceMenuConfigure', ]; } } diff --git a/application/src/Subscriber/UserMenuSubscriber.php b/application/src/Subscriber/UserMenuSubscriber.php index 919c729..ac475f1 100644 --- a/application/src/Subscriber/UserMenuSubscriber.php +++ b/application/src/Subscriber/UserMenuSubscriber.php @@ -2,11 +2,12 @@ namespace App\Subscriber; -use App\Event\Menu\Topbar\UserMenuEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Translation\TranslatorInterface; use Knp\Menu\ItemInterface; +use App\Event\Menu\MenuEvent; +use App\DBAL\Types\MenuEventType; class UserMenuSubscriber implements EventSubscriberInterface { @@ -26,7 +27,7 @@ class UserMenuSubscriber implements EventSubscriberInterface $this->translator = $translator; } - public function onUserMenuConfigure(UserMenuEvent $event): void + public function onUserMenuConfigure(MenuEvent $event): void { $menu = $event->getItem(); $menu->addChild($this->translator->trans('start'), [ @@ -89,7 +90,7 @@ class UserMenuSubscriber implements EventSubscriberInterface public static function getSubscribedEvents(): array { return [ - UserMenuEvent::EVENT => 'onUserMenuConfigure', + MenuEventType::USER=> 'onUserMenuConfigure', ]; } }