NavigationLoadedEvent example

$request->query->set('depth', (string) $depth);

        $criteria = new Criteria();
        $criteria->setTitle('header::navigation');

        $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) {
            
Home | Imprint | This part of the site doesn't use cookies.