src/Listener/AdminMenuSubscriber.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Listener;
  3. use Moka\Cms\Admin\Event\ConfigureMenuEvent;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. class AdminMenuSubscriber implements EventSubscriberInterface
  6. {
  7.     public static function getSubscribedEvents(): array
  8.     {
  9.         return [
  10.             ConfigureMenuEvent::CONFIGURE => 'configure',
  11.         ];
  12.     }
  13.     public function configure(ConfigureMenuEvent $event): void
  14.     {
  15.         $menu $event->getMenu();
  16.         // CONTENT
  17.         $contentSection $menu->addChild('content', [
  18.             'label' => 'Contenus',
  19.         ]);
  20.         $contentSection->addChild('entry_news'$this->addEntryLink('news''Actualités'));
  21.         $contentSection->addChild('entry_store'$this->addEntryLink('store''Magasins'));
  22.         $contentSection->addChild('entry_page'$this->addEntryLink('page''Pages'));
  23.         $contentSection->addChild('entry_category'$this->addEntryLink('category''Catégories'));
  24.         $contentSection->addChild('entry_product'$this->addEntryLink('product''Produits'));
  25.         $contentSection->addChild('entry_brand'$this->addEntryLink('brand''Marques'));
  26.         $contentSection->addChild('entry_singles_list', [
  27.             'label' => 'Pages spécifiques',
  28.             'route' => 'moka_admin_entry_singles',
  29.         ]);
  30.         // OBJECTS
  31.         $objectSection $menu->addChild('object', [
  32.             'label' => 'Objets',
  33.         ]);
  34.         $objectSection->addChild('entry_fag'$this->addEntryLink('faq''FAQ'));
  35.         $objectSection->addChild('entry_thematic'$this->addEntryLink('thematic''Thématiques d\'actualité'));
  36.         $objectSection->addChild('entry_tag'$this->addEntryLink('tag''Tags produits'));
  37.         $objectSection->addChild('product', [
  38.             'label' => 'Attributs produit',
  39.             'route' => 'admin_product_attribute_index',
  40.         ]);
  41.         $objectSection->addChild('entry_reinsurance'$this->addEntryLink('reinsurance''Réassurances'));
  42.         $objectSection->addChild('entry_discount'$this->addEntryLink('discount''Promotions'));
  43.         $menu->getChild('configuration')->removeChild('entry_taxonomies_list');
  44.         $menu->reorderChildren([
  45.             'dashboard',
  46.             'content',
  47.             'object',
  48.             'configuration',
  49.         ]);
  50.         // Business
  51.         $businessSection $menu->addChild('business', [
  52.             'label' => 'Business',
  53.         ]);
  54.         $businessSection->addChild('contact_requests', [
  55.             'label' => 'Demandes de contact',
  56.             'route' => 'admin_contact_request_index',
  57.         ]);
  58.         $businessSection->addChild('affiliate_requests', [
  59.             'label' => 'Demandes d\'affiliation',
  60.             'route' => 'admin_affiliate_request_index',
  61.         ]);
  62.     }
  63.     private function addEntryLink(string $typestring $label): array
  64.     {
  65.         return [
  66.             'label' => $label,
  67.             'route' => 'moka_admin_entry_index',
  68.             'routeParameters' => ['type' => $type],
  69.         ];
  70.     }
  71. }