Example #1
0
 public function load($name = 'main', Item $item = null, $paramList = [], $activeOnly = false)
 {
     $menu = null;
     if ($item != null) {
         $menu = $this->findMenu($item->getSubList(), $name);
     } else {
         if ($this->activeItem != null) {
             $menu = $this->findMenu($this->activeItem->getSubList(), $name);
             if ($menu == null) {
                 $menu = $this->findMenuReverse($this->activeItem, $name);
             }
         }
         if ($menu == null && !$activeOnly) {
             $menu = $this->findMenu($this->menuList, $name);
         }
     }
     /*
      * // Be paranoid, menus should already be there
      * if($menu == null) {
      * $config = $this->findConfig($this->config, $name);
      *
      * if($config == null)
      * throw new MenuManagerException('No ' . $name . ' menu config found');
      *
      * $config['params'] = $paramList;
      * $menu = new Menu($this->app, $config);
      * $this->menuList[] = $menu;
      * } else
      *
      */
     if ($menu != null) {
         if (!empty($paramList) && $menu->getParamList() != $paramList) {
             $menu->setParamList($paramList);
         }
         $menu->initActive();
     }
     $this->eventDispatcher->dispatch(MenuManagerListener::EVENT_MENU_LOADED);
     return $menu;
 }