示例#1
0
 public function createMenu(array $options)
 {
     parent::createMenu($options);
     $name = 'list';
     if (isset($options['name'])) {
         $name = $options['name'];
     }
     $menu = $this->getFactory()->createItem($name);
     foreach ($this->menu as $name => $itemOptions) {
         /** @var MenuBuilderInterface $menuBuilder */
         $menuBuilder = $this->menuItemTypeCollector->getType($itemOptions['type']);
         $itemOptions['name'] = $name;
         if ($menuBuilder->isGranted()) {
             $menu->addChild($menuBuilder->createMenu($itemOptions));
         }
     }
     return $menu;
 }
示例#2
0
 public function createMenu(array $options)
 {
     parent::createMenu($options);
     $name = 'base';
     if (isset($options['name'])) {
         $name = $options['name'];
     }
     $menu = $this->getFactory()->createItem($name);
     $translationDomain = null;
     if (isset($options['translationDomain'])) {
         $translationDomain = $options['translationDomain'];
     }
     if (isset($options['label'])) {
         $menu->setLabel($this->getTranslator()->trans($options['label'], [], $translationDomain));
     }
     if (isset($options['route'])) {
         $menu->setUri($this->getRouter()->generate($options['route']));
     }
     if (isset($options['icon'])) {
         $menu->setIcon($options['icon']);
     }
     return $menu;
 }