<?php
namespace App\EventListener;
use Sylius\Bundle\UiBundle\Menu\Event\MenuBuilderEvent;
use Sylius\Bundle\AdminBundle\Event\CustomerShowMenuBuilderEvent;
use Knp\Menu\ItemInterface;
use Knp\Menu\Util\MenuManipulator;
final class MenuBuilderListener
{
private $manipulator;
public function __construct(MenuManipulator $manipulator)
{
$this->manipulator = $manipulator;
}
/**
* @param MenuBuilderEvent $event
*/
public function addCustomerShowMenuItems(CustomerShowMenuBuilderEvent $event)
{
$menu = $event->getMenu();
unset($menu['user_delete']);
$menu->addChild('customer_synchronize', [
'route' => 'app_admin_customer_synchronize_single_customer',
'routeParameters' => ['id' => $event->getCustomer()->getId()],
])
->setLabel('Synchroniser le client');
$this->manipulator->moveToFirstPosition($menu['customer_synchronize']);
}
/**
* @param MenuBuilderEvent $event
*/
public function addBackendMenuItems(MenuBuilderEvent $event)
{
$menu = $event->getMenu();
$this->addBackendSiteMenu($menu);
$this->manipulator->moveToFirstPosition($menu['site']);
$this->manipulator->moveToLastPosition($menu['configuration']);
$this->manipulator->moveToLastPosition($menu['bitbag_cms']);
}
public function addBackendSiteMenu(ItemInterface $menu)
{
// dump($menu);
$siteSubMenu = $menu
->addChild('site')
->setLabel('Site')
;
$siteSubMenu
->addChild('site-help', ['route' => 'app_admin_help'])
->setLabel('Aide à la gestion du site')
->setLabelAttribute('icon', 'help')
;
$siteSubMenu
->addChild('site-shop', ['route' => 'app_admin_site_shop_index'])
->setLabel('Boutiques PPMC')
->setLabelAttribute('icon', 'shopping basket')
;
$siteSubMenu
->addChild('site-apel', ['route' => 'app_admin_site_apel_index'])
->setLabel('APEL')
->setLabelAttribute('icon', 'shopping basket')
;
$siteSubMenu
->addChild('site-menu-header', ['route' => 'app_admin_site_menu_header_create'])
->setLabel('Menu Header')
->setLabelAttribute('icon', 'list')
;
$siteSubMenu
->addChild('site-menu-footer', ['route' => 'app_admin_site_menu_footer_index'])
->setLabel('Menu Footer')
->setLabelAttribute('icon', 'list')
;
$siteSubMenu
->addChild('accueil-slide', ['route' => 'app_admin_site_home_slide_index'])
->setLabel('Accueil - Slides')
->setLabelAttribute('icon', 'images outline')
;
$siteSubMenu
->addChild('accueil-declinaison', ['route' => 'app_admin_site_home_product_variant_index'])
->setLabel('Accueil - Déclinaisons produits')
->setLabelAttribute('icon', 'list alternate')
;
$siteSubMenu
->addChild('accueil-saison', ['route' => 'app_admin_site_home_slide_saison_index'])
->setLabel('Accueil - Slides Saison')
->setLabelAttribute('icon', 'images')
;
$siteSubMenu
->addChild('accueil-imprime', ['route' => 'app_admin_site_home_imprime_index'])
->setLabel('Accueil - Bloc "Imprimés"')
->setLabelAttribute('icon', 'print')
;
$siteSubMenu
->addChild('accueil-vouslesadorez', ['route' => 'app_admin_site_home_main_taxon_index'])
->setLabel('Accueil - "Vous les adorez !"')
->setLabelAttribute('icon', 'heartbeat')
;
$siteSubMenu
->addChild('accueil-coteboutique', ['route' => 'app_admin_site_home_coteboutique_index'])
->setLabel('Accueil - Bloc "Côté Boutique"')
->setLabelAttribute('icon', 'shopping bag')
;
$siteSubMenu
->addChild('gift-idea-link', ['route' => 'app_admin_site_gift_idea_link_index'])
->setLabel('Idées cadeaux - Liens')
->setLabelAttribute('icon', 'linkify')
;
$siteSubMenu
->addChild('site-bloc-insurance', ['route' => 'app_admin_site_bloc_insurance_index'])
->setLabel('Blocs Assurance')
->setLabelAttribute('icon', 'block layout')
;
$siteSubMenu
->addChild('site-sac-zip-accessories', ['route' => 'app_admin_site_sac_zip_accessories_index'])
->setLabel('Sac&Zip - Accessoires')
->setLabelAttribute('icon', 'shopping bag')
;
$siteSubMenu
->addChild('site-sac-zip-combinaisons', ['route' => 'app_admin_site_sac_zip_selection_index'])
->setLabel('Sac&Zip - Combinaisons')
->setLabelAttribute('icon', 'random')
;
$menu['catalog']
->addChild('collections-colors', ['route' => 'app_admin_site_product_option_value_match_index'])
->setLabel('Associations de collections')
->setLabelAttribute('icon', 'paint brush alternate')
;
$menu['catalog']
->addChild('site-faq-product', ['route' => 'app_admin_site_faq_product_index'])
->setLabel('FAQ Produit')
->setLabelAttribute('icon', 'question circle')
;
$menu['catalog']
->addChild('site-filter-facet', ['route' => 'app_admin_site_filter_facet_index'])
->setLabel('Filtres à facettes')
->setLabelAttribute('icon', 'filter')
;
$menu['catalog']
->addChild('site-collection', ['route' => 'app_admin_site_collection_index'])
->setLabel('Collections')
->setLabelAttribute('icon', 'magic')
;
$siteSubMenu = $menu
->addChild('search-engine')
->setLabel('Moteur de recherche')
;
$menu['search-engine']
->addChild('site-search-suggest-text', ['route' => 'app_admin_site_search_suggest_text_index'])
->setLabel("Suggestions de recherche")
->setLabelAttribute('icon', 'tasks')
;
$menu['search-engine']
->addChild('site-search-suggest-product-variant', ['route' => 'app_admin_site_search_suggest_product_variant_index'])
->setLabel("Suggestions de produits")
->setLabelAttribute('icon', 'cubes')
;
$siteSubMenu = $menu
->addChild('articles-pages-cms')
->setLabel('Gestion du contenu')
;
$menu['articles-pages-cms']
->addChild('site-article-categories', ['route' => 'app_admin_site_article_category_index'])
->setLabel("Catégories d'articles")
->setLabelAttribute('icon', 'folder')
;
$menu['articles-pages-cms']
->addChild('site-article', ['route' => 'app_admin_site_article_index'])
->setLabel("Articles")
->setLabelAttribute('icon', 'pencil alternate')
;
$menu['articles-pages-cms']
->addChild('site-page-cms', ['route' => 'app_admin_site_page_cms_index'])
->setLabel("Pages CMS")
->setLabelAttribute('icon', 'paste alternate')
;
$menu['articles-pages-cms']
->addChild('site-faq-category', ['route' => 'app_admin_site_faq_category_index'])
->setLabel("Catégories - FAQ")
->setLabelAttribute('icon', 'help alternate')
;
$menu['articles-pages-cms']
->addChild('site-faq', ['route' => 'app_admin_site_faq_index'])
->setLabel("FAQ")
->setLabelAttribute('icon', 'help alternate')
;
$menu['articles-pages-cms']
->addChild('site-selection-categories', ['route' => 'app_admin_site_selection_category_index'])
->setLabel("Catégories de sélections")
->setLabelAttribute('icon', 'folder')
;
$menu['articles-pages-cms']
->addChild('site-selection', ['route' => 'app_admin_site_selection_index'])
->setLabel("Sélections")
->setLabelAttribute('icon', 'pencil alternate')
;
$menu['customers']
->addChild('site-contact', ['route' => 'app_admin_site_contact_index'])
->setLabel('Formulaire de contact')
->setLabelAttribute('icon', 'paint brush alternate')
;
$menu['sales']
->addChild('parameters', ['route' => 'app_admin_sylius_sales_parameter_index'])
->setLabel('Configuration')
->setLabelAttribute('icon', 'cog')
;
$menu['catalog']
->addChild('site-variants-attributes', ['route' => 'app_admin_variants_attributes_index'])
->setLabel('Variants/Caractéristiques')
->setLabelAttribute('icon', 'paint map signs alternate')
;
$menu['catalog']
->addChild('site-variants-taxons', ['route' => 'app_admin_variants_taxons_index'])
->setLabel('Variants/Taxons')
->setLabelAttribute('icon', 'paint map signs alternate')
;
}
public function addProductVariantItem(MenuBuilderEvent $event)
{
$menu = $event->getMenu();
$menu
->addChild('attributes')
->setAttribute('template', '@SyliusAdmin/ProductVariant/Tab/_attributes.html.twig')
->setLabel('Caractéristiques')
;
}
}