Esempio n. 1
0
 /**
  * Add bundle to the category.
  *
  * @param CategoryTypesEvent $event
  */
 public function onCategoryBundleListBuild(CategoryTypesEvent $event)
 {
     $bundles = $this->bundleHelper->getMauticBundles(true);
     foreach ($bundles as $bundle) {
         if (!empty($bundle['config']['categories'])) {
             foreach ($bundle['config']['categories'] as $type => $label) {
                 $event->addCategoryType($type, $label);
             }
         }
     }
 }
Esempio n. 2
0
 /**
  * @param IconEvent $event
  */
 public function onFetchIcons(IconEvent $event)
 {
     $session = $this->request->getSession();
     $icons = $session->get('mautic.menu.icons', []);
     if (empty($icons)) {
         $bundles = $this->bundleHelper->getMauticBundles(true);
         foreach ($bundles as $bundle) {
             if (!empty($bundle['config']['menu']['main'])) {
                 $items = !isset($bundle['config']['menu']['main']['items']) ? $bundle['config']['menu']['main'] : $bundle['config']['menu']['main']['items'];
             }
             if (!empty($items)) {
                 $this->menuHelper->createMenuStructure($items);
                 foreach ($items as $item) {
                     if (isset($item['iconClass']) && isset($item['id'])) {
                         $id = explode('_', $item['id']);
                         if (isset($id[1])) {
                             // some bundle names are in plural, create also singular item
                             if (substr($id[1], -1) == 's') {
                                 $event->addIcon(rtrim($id[1], 's'), $item['iconClass']);
                             }
                             $event->addIcon($id[1], $item['iconClass']);
                         }
                     }
                 }
             }
         }
         unset($bundles, $menuHelper);
         $icons = $event->getIcons();
         $session->set('mautic.menu.icons', $icons);
     } else {
         $event->setIcons($icons);
     }
 }