<?php
namespace App\Listener;
use Moka\Cms\Admin\Event\ConfigureMenuEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class AdminMenuSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
ConfigureMenuEvent::CONFIGURE => 'configure',
];
}
public function configure(ConfigureMenuEvent $event): void
{
$menu = $event->getMenu();
// CONTENT
$contentSection = $menu->addChild('content', [
'label' => 'Contenus',
]);
$contentSection->addChild('entry_news', $this->addEntryLink('news', 'Actualités'));
$contentSection->addChild('entry_store', $this->addEntryLink('store', 'Magasins'));
$contentSection->addChild('entry_page', $this->addEntryLink('page', 'Pages'));
$contentSection->addChild('entry_category', $this->addEntryLink('category', 'Catégories'));
$contentSection->addChild('entry_product', $this->addEntryLink('product', 'Produits'));
$contentSection->addChild('entry_brand', $this->addEntryLink('brand', 'Marques'));
$contentSection->addChild('entry_singles_list', [
'label' => 'Pages spécifiques',
'route' => 'moka_admin_entry_singles',
]);
// OBJECTS
$objectSection = $menu->addChild('object', [
'label' => 'Objets',
]);
$objectSection->addChild('entry_fag', $this->addEntryLink('faq', 'FAQ'));
$objectSection->addChild('entry_thematic', $this->addEntryLink('thematic', 'Thématiques d\'actualité'));
$objectSection->addChild('entry_tag', $this->addEntryLink('tag', 'Tags produits'));
$objectSection->addChild('product', [
'label' => 'Attributs produit',
'route' => 'admin_product_attribute_index',
]);
$objectSection->addChild('entry_reinsurance', $this->addEntryLink('reinsurance', 'Réassurances'));
$objectSection->addChild('entry_discount', $this->addEntryLink('discount', 'Promotions'));
$menu->getChild('configuration')->removeChild('entry_taxonomies_list');
$menu->reorderChildren([
'dashboard',
'content',
'object',
'configuration',
]);
// Business
$businessSection = $menu->addChild('business', [
'label' => 'Business',
]);
$businessSection->addChild('contact_requests', [
'label' => 'Demandes de contact',
'route' => 'admin_contact_request_index',
]);
$businessSection->addChild('affiliate_requests', [
'label' => 'Demandes d\'affiliation',
'route' => 'admin_affiliate_request_index',
]);
}
private function addEntryLink(string $type, string $label): array
{
return [
'label' => $label,
'route' => 'moka_admin_entry_index',
'routeParameters' => ['type' => $type],
];
}
}