src/Http/Admin/Menu/ReportSubscriber.php line 66

Open in your IDE?
  1. <?php
  2. namespace App\Http\Admin\Menu;
  3. use App\Infrastructure\Menu\Data\Menu;
  4. use App\Infrastructure\Menu\Event\MenuAdminEvent;
  5. use Knp\Menu\ItemInterface;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. class ReportSubscriber extends  Menu implements EventSubscriberInterface
  8. {
  9.     /**
  10.      * @var ItemInterface
  11.      */
  12.     protected $menu;
  13.     /**
  14.      * Items to add in menu
  15.      *
  16.      * @var        array
  17.      */
  18.     private static $items = array(
  19.         [
  20.             'Rapports',
  21.             [
  22.                 'attributes' => [
  23.                     'type' => 'heading'
  24.                 ]
  25.             ],
  26.             []
  27.         ],
  28.         [
  29.             'Commandes',
  30.             [
  31.                 'route'      => 'admin_report_order',
  32.                 'attributes' => [
  33.                     'permission' => [
  34.                         'attribute' => 'module_report_order',
  35.                         'object' => ''
  36.                     ]
  37.                 ]
  38.             ],
  39.             ['Rapports']
  40.         ],
  41.         [
  42.             'Produits',
  43.             [
  44.                 'route'      => 'admin_report_product',
  45.                 'attributes' => [
  46.                     'permission' => [
  47.                         'attribute' => 'module_report_product',
  48.                         'object' => ''
  49.                     ]
  50.                 ]
  51.             ],
  52.             ['Rapports']
  53.         ]
  54.     );
  55.     /**
  56.      * @param MenuAdminEvent $event
  57.      */
  58.     public function onMenuConfigure(MenuAdminEvent $event)
  59.     {
  60.         $this->menu $event->getMenu();
  61.         foreach (self::$items as $data) {
  62.             $this->addItem($data[0], $data[1], $data[2]);
  63.         }
  64.     }
  65.     public static function getSubscribedEvents()
  66.     {
  67.         return [
  68.             MenuAdminEvent::CONFIGURE => ['onMenuConfigure',96],
  69.         ];
  70.     }
  71. }