/**
  * @param \App\type $id
  * @return \App\ILinkSettings
  */
 public function create($id)
 {
     $item = $this->menuItemDataSource->get($id, function (Selection $context) {
         $symlinkTable = ':menu_has_symlink.symlink';
         $context->select("{$symlinkTable}.id, {$symlinkTable}.type");
         $context->where("{$symlinkTable}.type != ?", MenuTypeConst::SYMLINK);
         $context->where("{$symlinkTable}.id IS NOT NULL");
     });
     return $this->menuLinkMap->get($item['type'])->create($item['id']);
 }
Ejemplo n.º 2
0
 /**
  * @param int $sectionId
  * @param $module
  * @param MenuLinkMap $menuLinkMap
  * @return \App\Widget\MenuView
  */
 public function create($sectionId, $module, MenuLinkMap $menuLinkMap)
 {
     $tree = $this->menuTreeFactory->create($sectionId);
     $tree->onNodeCreated[] = function ($node, $data) use($menuLinkMap) {
         $node->name = $data->name;
         $node->type = $data->type;
         $node->html = NULL;
         if ($this->menuItemHelper->isMenuItemLink($data->type)) {
             try {
                 $node->link = $menuLinkMap->get($data->type)->create($data->id);
             } catch (InvalidArgumentException $e) {
                 $node->link = NULL;
             }
         } else {
             $node->html = $data->html;
         }
     };
     return $this->menuViewFactory->create($sectionId, $module, $tree);
 }