<?php
/**
* Created by Elements.at New Media Solutions GmbH
*
*/
namespace App\EventSubscriber;
use Elements\Bundle\BackendDashboardBundle\Component\Pimcore\Menu\MenuItem;
use Elements\Bundle\BackendDashboardBundle\Component\Pimcore\Menu\MenuTree;
use Elements\Bundle\BackendDashboardBundle\Constants\Event;
use Elements\Bundle\BackendDashboardBundle\Event\AddMenuItemsEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Routing\RouterInterface;
class MenuSubscriber implements EventSubscriberInterface
{
/**
* @var RouterInterface
*/
private $router;
public function __construct(RouterInterface $router)
{
$this->router = $router;
}
/**
* @return string[]
*/
public static function getSubscribedEvents()
{
return [
Event::MENU_ADD_CUSTOM_ITEMS => 'addDashboardMenuItems',
];
}
/**
* @param AddMenuItemsEvent $event
*
* @return void
*/
public function addDashboardMenuItems(AddMenuItemsEvent $event): void
{
$router = $this->router;
$menuTree = $event->getRootMenuTree();
$mainItem = new MenuItem('Back Office - Ordering', '', 'pimcore_nav_icon_commerce_backoffice', '/bundles/pimcoreadmin/img/flat-white-icons/list.svg');
$icon = 'pimcore_nav_icon_commerce_backoffice';
$icon_svg = '/bundles/pimcoreadmin/img/flat-white-icons/list.svg';
$list = [
new MenuItem('Dashboard', $router->generate('app_backoffice_dashboard'), $icon, $icon_svg),
new MenuItem('Order List', $router->generate('app_backoffice_orderlist'), $icon, $icon_svg),
new MenuItem('Capture Event', $router->generate('app_backoffice_captureevent'), $icon, $icon_svg),
new MenuItem('List Events', $router->generate('app_backoffice_event_list'), $icon, $icon_svg),
new MenuItem('Accounting List', $router->generate('app_backoffice_accounting_list'), $icon, $icon_svg),
new MenuItem('Customer List', $router->generate('app_backoffice_customerdata'), $icon, $icon_svg),
new MenuItem('Merchandise Controll', $router->generate('app_backoffice_merch'), $icon, $icon_svg),
// new MenuItem('Authors Charts', $router->generate('app_dashboard_authors_charts'))
];
$tree = new MenuTree($menuTree, $mainItem, $list);
/** @phpstan-ignore-next-line */
$menuTree->setChildren([$tree]);
}
}