@param $menu MenuItem
@param array $nodesList

@return array
196372
public function renderMenu($menu, $nodesList)
    {
        $menuManger = $this->getContainer()->get('compo_menu.manager');

        foreach ($nodesList as $key => $item) {
            /** @var \Compo\MenuBundle\Entity\MenuItem $nodeItem */
            $nodeItem = $item['node'];

            if (!$nodeItem->getEnabled()) {
                unset($nodesList[$key]);
                continue;
            }

            $targetId = $nodeItem->getTargetId();
            $type = $nodeItem->getType();

            if ('url' !== $type && $targetId) {
                $menuType = $menuManger->getMenuType($type);

                $menuType->fillMenuItem($item);
            } else {
                $nodeItem->setType('url');
                $item['url'] = $nodeItem->getUrl();
            }

            $item['node'] = $nodeItem;

            $image = $nodeItem->getImage();

            if ($image) {
                $item['image'] = $image;
            } else {
                $item['image'] = null;
            }

            /** @var MenuItem $node */
            $node = $menu->addChild($item['id'], ['uri' => $item['url']]);

            if ($item['url'] === $this->getRequest()->getRequestUri()) {
                // URL's completely match
                $node->setCurrent(true);
            } elseif ($item['url'] && $item['url'] !== $this->getRequest()->getBaseUrl() . '/' && (0 === mb_strpos($this->getRequest()->getRequestUri(), $item['url']))) {
                // URL isn't just "/" and the first container of the URL match
                $node->setCurrent(true);
            }

            if (\count($item['__children'])) {
                $item['__children'] = $this->renderMenu($node, $item['__children']);
            }

            $nodesList[$key] = $item;
        }

        return $nodesList;
    }
269068
private function getNewMenuOrder(ItemInterface $menu): array
    {
        $menuOrder = array_keys($menu->getChildren());
        $configMenuIndex = array_search('configuration', $menuOrder, true);
        if ($configMenuIndex !== false) {
            array_splice($menuOrder, $configMenuIndex, 0, ['nglayouts']);

            return $menuOrder;
        }

        $menuOrder[] = 'nglayouts';

        return $menuOrder;
    }
333980
protected function _prepareIconList(array &$iconList) {
		if (empty($iconList) || !is_array($iconList)) {
			return;
		}

		foreach ($iconList as $i => &$iconListItem) {
			if (is_array($iconListItem) && isAssoc($iconListItem)) {
				foreach ($iconListItem as $topMenu => $subMenu) {
					$subMenuList = '';
					foreach ($subMenu as $subMenuItem) {
						$subMenuClass = null;
						if ($subMenuItem === 'divider') {
							$subMenuItem = '';
							$subMenuClass = 'divider';
						}
						$subMenuList .= $this->Html->tag('li', $subMenuItem, ['class' => $subMenuClass]);
					}
					$topMenuItem = $topMenu . $this->Html->tag('ul', $subMenuList, ['class' => 'dropdown-menu']);
				}
				$iconListItem = $topMenuItem;
			}
		}
	}
574035
public function getParentMenu(Menu $menu, MenuItem $childNode)
    {
        $itemIterator = new RecursiveItemIterator($menu->getIterator());
        $iterator = new \RecursiveIteratorIterator($itemIterator, \RecursiveIteratorIterator::SELF_FIRST);
        foreach ($iterator as $menuItem) {
            $parentId = $childNode->getParent()->getId();
            if ($menuItem->getName() != $parentId) {
                continue;
            }

            return $menuItem;
        }

        return false;
    }
132859
private function applyFiltersToMenuNodes(
        ArrayCollection $menuNodes,
        $menuCode,
        $stage
    ) {
        return $menuNodes->filter(function (NodeInterface $menuNode) use ($menuCode, $stage) {

            if ($this->applyFiltersToMenuNode(
                $menuNode,
                $menuCode,
                $stage
            )
            ) {
                $menuNode->setSubnodes(
                    $this->applyFiltersToMenuNodes(
                        $menuNode->getSubnodes(),
                        $menuCode,
                        $stage
                    )
                );

                return true;
            }

            return false;
        });
    }
673638
public function findBy(string $key, string $value, callable $callback = null): ?MenuItem
    {
        $item = $this->items->filter(function ($item) use ($key, $value) {
            return $item->{$key} === $value;
        })->first();

        (! is_callable($callback) || ! $item) || call_user_func($callback, $item);

        return $item;
    }
486457
static function fetchNodePathString( $nodeList )
    {
        $pathList = array();
        foreach ( $nodeList as $node )
        {
            $pathList[] = $node->attribute( 'path_string' );
        }
        return $pathList;
    }
669439
private function parseMenu(\DOMNode $menu) {

		$root = $menu->getAttribute('script');

		if(!$root) {
			if($this->site) {
				$root= $this->site->root_document ?: 'index.php';
			}
			else {
				$root= 'index.php';
			}
		}

		$type = $menu->getAttribute('type') === 'dynamic' ? 'dynamic' : 'static';
		$service = $menu->getAttribute('service') ?: NULL;
		$id = $menu->getAttribute('id') ?: NULL;

		if($type === 'dynamic' && !$service) {
			throw new ConfigException("A dynamic menu requires a configured service.");
		}

		$m = new Menu(
			$root,
			$id,
			$type,
			$service
		);

		if(($menuAuth = strtolower(trim($menu->getAttribute('auth'))))) {

			$m->setAuth($menuAuth);

			// if an auth level is defined, additional authentication parameters can be set

			if(($authParameters = $menu->getAttribute('auth_parameters'))) {
				$m->setAuthParameters($authParameters);
			}

		}

		$this->appendMenuEntries($menu->childNodes, $m);

		return $m;

	}
702330
public function createMenu(array $options = []): ItemInterface
    {
        // Create Root
        $menu = $this->createRoot('mail_manager')->setChildAttr([
            'class' => 'nav nav-pills',
            'data-parent' => 'admin_mail_list',
        ]);

        // Create Menu Items
        $menu
            ->addChild('nav_mail_template')
            ->setLabel('nav_mail_template')
            ->setRoute('admin_mail_list')
            ->setRoles(['ROLE_MAIL_TEMPLATELIST'])
            // Logger
            ->addChildParent('nav_mail_logger')
            ->setLabel('nav_mail_logger')
            ->setRoute('admin_mail_logger')
            ->setRoles(['ROLE_MAIL_LOGGER']);

        return $menu;
    }
267650
public function siblings($selector = null): NodeList {
        $results = $this->collection()->reduce(function($carry, $node) use ($selector) {
            return $carry->merge(
                $node->precedingAll($selector)->merge(
                    $node->followingAll($selector)
                )
            );
        }, $this->newNodeList());

        return $results;
    }
1344361
public static function parentID($menuLinkID)
    {
        $parentIDs = [];
        while($menuLinkID != null){
            $parentObj = MenuLink::all()->where('menuLinkID', $menuLinkID)->first();
            if ($parentObj) {
                $menuLinkID = $parentObj->parent;
                if ($menuLinkID) {
                    $parentIDs[] = $menuLinkID;
                }
            }
            if ($parentObj || !$menuLinkID) {
                $menuLinkID = null;
            }
        }
        return $parentIDs;
    }
481704
public function getMenuItems($menu) {
		if( !isset(self::$menusConf) ) {
			self::$menusConf = IniConfig::build('menus', true);
		}
		if( empty(self::$menusConf) || empty(self::$menusConf->$menu) ) {
			return array();
		}
		return self::$menusConf->$menu;
	}
1203011
public function newMenuItemAction(Menu $menu)
    {
        $em = $this->getDoctrine()->getManager();

        $entity = new MenuItem();
        $entity->setMenu($menu);
        $form = $this->createMenuItemCreateForm($entity);

        return array(
            'entity' => $entity,
            'form' => $form->createView(),
        );
    }
296611
private function addMenuItems(Item $parent, array $menu): void
	{
		foreach ($menu as $name => $item) {

			if (array_key_exists('link', $item)) {
				$link = $parent->addLink($name, $item['link'], isset($item['arguments']) ? $item['arguments'] : []);
				if (!empty($item['toBlank'])) {
					$link->toBlank();
				}
				if (!empty($item['count'])) {
					$this->setCount($link, $item['count']);
				}
				unset($item['link'], $item['arguments'], $item['toBlank'], $item['count']);
			} else {
				$link = $parent->addGroup($name);
			}
			$this->addMenuItems($link, $item);
		}
	}
690478
function preloadDependencies(array $nodeIdList)
    {
        $siteIdList = [];

        $nodeList = parent::preloadDependencies($nodeIdList);

        foreach ($nodeList as $node) {
            foreach ($node->ucms_sites as $siteId) {
                $siteIdList[$siteId] = $siteId;
            }
        }

        if ($siteIdList) {
            $this->siteManager->getStorage()->loadAll($siteIdList);
        }

        return $nodeList;
    }
471432
public function createFromMenuItem(MenuItem $menuItem)
    {
        if ($path = $menuItem->getPath()) {
            $uri = $this->request->getBaseUrl().$path;
        } elseif ($menuItem->getRedirectUrl()) {
            $uri = $menuItem->getRedirectUrl();
        } elseif ($menuItem->getInternalUrl()) {
            $uri = $this->request->getBaseUrl().$menuItem->getInternalUrl();
        } elseif ($contentRoute = $menuItem->getContentRoute()) {
            $route = ContentRouteManager::generateRoute($contentRoute, $contentRoute->getPath(), '');
            $uri = $this->request->getBaseUrl().$route->getPath();
        } else {
            $uri = '#';
        }

        $options = [
            'uri' => $uri,
            'label' => $menuItem->getName(),
            'attributes' => [],
            'linkAttributes' => $menuItem->getLinkAttributes(),
            'childrenAttributes' => [],
            'labelAttributes' => [],
            'extras' => [],
            'display' => true,
            'displayChildren' => true,

        ];
        $item = $this->factory->createItem($menuItem->getId(), $options);

        if ($menuItem->isHidden()) {
            $item->setDisplay(false);
        }

        return $item;
    }
408175
public static function appendChildrenNodeIDs( &$nodeList, &$nodeIDList )
    {
        $params = array( 'Depth' => 1,
                         'AsObject' => false );
        foreach ( $nodeList as $node )
        {
            $childNodeList = eZContentObjectTreeNode::subTreeByNodeID( $params, $node->attribute( 'node_id' ) );
            if ( !empty( $childNodeList ) )
            {
                foreach ( $childNodeList as $childNode )
                {
                    $nodeIDList[] = $childNode['node_id'];
                }
            }
        }
    }