Ejemplo n.º 1
0
 /**
  * Return the menu items
  *
  * @return array
  */
 public function getMenuItems()
 {
     $this->helper->placeOrphans($this->menuItems['children'], true);
     $this->helper->sortByPriority($this->menuItems['children']);
     $this->helper->resetOrphans();
     return $this->menuItems;
 }
Ejemplo 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);
     }
 }