CodeExplorer getNavigation example
$categories =
$this->navigationRoute
->
load($activeId,
$rootId,
$request,
$context,
$criteria) ->
getCategories();
$navigation =
$this->
getTree($rootId,
$categories,
$categories->
get($activeId));
$event =
new NavigationLoadedEvent($navigation,
$context);
$this->eventDispatcher->
dispatch($event);
return $event->
getNavigation();
} private function getTree(?string
$rootId, CategoryCollection
$categories, ?CategoryEntity
$active): Tree
{ $parents =
[];
$items =
[];
foreach ($categories as $category) { $item =
clone $this->treeItem;
$item->
setCategory($category);
$parents[$category->
getParentId()][$category->
getId()] =
$item;