Exemplo n.º 1
0
 /**
  * getTreeCollection
  *
  * @return TreeCollection
  */
 private function getTreeCollection()
 {
     $treeRows = [0 => ["id" => "aboutUs", "menuId" => "main", "parentId" => "main", "title" => " 소개", "url" => "aboutUs", "description" => "ddd", "target" => "_self", "type" => "pluginB@page", "ordering" => 0, "activated" => 1, "options" => "", "depth" => 1, "breadcrumbs" => "main,aboutUs"], 1 => ["id" => "freeboard", "menuId" => "main", "parentId" => "main", "title" => "자유게시판", "url" => "freeboard", "description" => "자게입니다.", "target" => "_self", "type" => "pluginA@board", "ordering" => 0, "activated" => 1, "options" => "", "depth" => 1, "breadcrumbs" => "main,freeboard"], 2 => ["id" => "test", "menuId" => "main", "parentId" => "freeboard", "title" => "test", "url" => "test", "description" => "test", "target" => "_self", "type" => "pluginB@widgetPage", "ordering" => 0, "activated" => 1, "options" => "", "depth" => 2, "breadcrumbs" => "main,freeboard,test"], 3 => ["id" => "notice", "menuId" => "main", "parentId" => "main", "title" => "공지 게시판", "url" => "notice", "description" => "공지사항 게시판입니다.", "target" => "_self", "type" => "pluginA@board", "ordering" => 1, "activated" => 1, "options" => "", "depth" => 1, "breadcrumbs" => "main,notice"]];
     $nodes = [];
     foreach ($treeRows as $row) {
         $node = new MenuItem(array_diff_key($row, array_flip(['depth', 'breadcrumbs'])));
         $node->setdepth($row['depth']);
         $node->setBreadcrumbs(explode(',', $row['breadcrumbs']));
         $nodes[$node->id] = $node;
     }
     return new TreeCollection($nodes);
 }