/** * Traverses the menu recursively finding sub menus * * @param $depth * @param $page * @param $menu * @return mixed */ private function traverseMenu($menu, $depth, $page) { $cache = MenuCache::loadMenu($menu->name); if (!$cache) { $lazyLoadString = $this->getLazyLoadByDepth('items', $depth); $menu->load($lazyLoadString); $menu->allowedMenuItems = $this->getAllowedMenuItemsFromMenu($menu); if ($page !== null) { $this->activeItemSiblings = array(); $this->activeItemChildren = array(); $this->locateCurrentMenuItem($page->id, $menu->allowedMenuItems); } MenuCache::saveMenu($menu, $this->activeItemChildren, $this->activeItemSiblings); } else { $menu = $cache['menu']; } return $menu->allowedMenuItems; }