src/EventSubscriber/MenuSubscriber.php line 44

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by Elements.at New Media Solutions GmbH
  4.  *
  5.  */
  6. namespace App\EventSubscriber;
  7. use Elements\Bundle\BackendDashboardBundle\Component\Pimcore\Menu\MenuItem;
  8. use Elements\Bundle\BackendDashboardBundle\Component\Pimcore\Menu\MenuTree;
  9. use Elements\Bundle\BackendDashboardBundle\Constants\Event;
  10. use Elements\Bundle\BackendDashboardBundle\Event\AddMenuItemsEvent;
  11. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  12. use Symfony\Component\Routing\RouterInterface;
  13. class MenuSubscriber implements EventSubscriberInterface
  14. {
  15.     /**
  16.      * @var RouterInterface
  17.      */
  18.     private $router;
  19.     public function __construct(RouterInterface $router)
  20.     {
  21.         $this->router $router;
  22.     }
  23.     /**
  24.      * @return string[]
  25.      */
  26.     public static function getSubscribedEvents()
  27.     {
  28.         return [
  29.             Event::MENU_ADD_CUSTOM_ITEMS => 'addDashboardMenuItems',
  30.         ];
  31.     }
  32.     /**
  33.      * @param AddMenuItemsEvent $event
  34.      *
  35.      * @return void
  36.      */
  37.     public function addDashboardMenuItems(AddMenuItemsEvent $event): void
  38.     {
  39.         $router $this->router;
  40.         $menuTree $event->getRootMenuTree();
  41.         $mainItem = new MenuItem('Back Office - Ordering''''pimcore_nav_icon_commerce_backoffice''/bundles/pimcoreadmin/img/flat-white-icons/list.svg');
  42.         $icon 'pimcore_nav_icon_commerce_backoffice';
  43.         $icon_svg '/bundles/pimcoreadmin/img/flat-white-icons/list.svg';
  44.         $list = [
  45.             new MenuItem('Dashboard'$router->generate('app_backoffice_dashboard'), $icon$icon_svg),
  46.             new MenuItem('Order List'$router->generate('app_backoffice_orderlist'), $icon$icon_svg),
  47.             new MenuItem('Capture Event'$router->generate('app_backoffice_captureevent'), $icon$icon_svg),
  48.             new MenuItem('List Events'$router->generate('app_backoffice_event_list'), $icon$icon_svg),
  49.             new MenuItem('Accounting List'$router->generate('app_backoffice_accounting_list'), $icon$icon_svg),
  50.             new MenuItem('Customer List'$router->generate('app_backoffice_customerdata'), $icon$icon_svg),
  51.             new MenuItem('Merchandise Controll'$router->generate('app_backoffice_merch'), $icon$icon_svg),
  52.             // new MenuItem('Authors Charts', $router->generate('app_dashboard_authors_charts'))
  53.         ];
  54.         $tree = new MenuTree($menuTree$mainItem$list);
  55.         /** @phpstan-ignore-next-line */
  56.         $menuTree->setChildren([$tree]);
  57.     }
  58. }