Add a menu item node at the correct place in the menu.

@param Menu $menu
@param MenuItem $node
@param $startDepth

@return bool|\Knp\Menu\ItemInterface
4579
public function addNodeToMenu(Menu $menu, MenuItem $node, $startDepth)
    {
        if ($node->getLvl() < $startDepth) {
            return false;
        }

        if ($node->getLvl() > $startDepth) {
            $menu = $this->getParentMenu($menu, $node);
        }

        if (is_object($menu)) {
            $knpMenuNode = $this->createFromMenuItem($node);
            if (!is_null($knpMenuNode)) {
                $menu->addChild($knpMenuNode);
                $knpMenuNode->setAttribute('class', $node->getLinkClass());
                $knpMenuNode->setExtra('translation_domain', false);
                if ($node->getVisibility() != MenuItem::VISIBILITY_PUBLIC && !$this->isLoggedIn) {
                    $knpMenuNode->setDisplay(false);
                }

                return $knpMenuNode;
            }
        }

        return false;
    }
1157912
public function add(MenuEntry $menu)
    {
        $menu->parent = $this;
        $menu->urlGenerator = $this->urlGenerator;
        $this->children[$menu->getName()] = $menu;

        return $menu;
    }
400737
public function addAdminMenuItem(MenuCollectionEvent $event): void
    {
        if (!$this->auth->isGranted('ROLE_ADMIN')) {
            return;
        }

        $menu = $event->getMenu();

        // Create admin menu item.
        $admin = $this->factory->createItem('menu_item.admin', [
            'route' => 'bkstg_admin_redirect',
            'extras' => [
                'icon' => 'wrench',
                'translation_domain' => BkstgCoreBundle::TRANSLATION_DOMAIN,
            ],
        ]);
        $menu->addChild($admin);
    }
712705
public function addDevelopmentItem($menuName, $url, $order = 50, $tooltip = false)
    {
        if (Development::isEnabled()) {
            $this->addItem('CoreAdminHome_MenuDevelopment', $menuName, $url, $order, $tooltip);
        }
    }
1258575
public function addMenuItem(MenuItem $menuItem, $position = -1) {
        if (!is_int($position)) {
            throw new InvalidArgumentException('position should be of type int.');
        }

        if ($position < 0) {
            $position = count($this->menuItems);
        }

        $menuItem->setOrder($position);

        Utils::array_insert($this->menuItems, $menuItem, $position);

        return $this;
    }
687326
private function addLayoutsSubMenu(ItemInterface $menu): void
    {
        $menuOrder = $this->getNewMenuOrder($menu);

        $layouts = $menu
            ->addChild('nglayouts')
            ->setLabel('menu.main_menu.header')
            ->setExtra('translation_domain', 'ngbm_admin');

        $layouts
            ->addChild('layout_resolver', ['route' => 'ngbm_admin_layout_resolver_index'])
            ->setLabel('menu.main_menu.layout_resolver')
            ->setExtra('translation_domain', 'ngbm_admin');

        $layouts
            ->addChild('layouts', ['route' => 'ngbm_admin_layouts_index'])
            ->setLabel('menu.main_menu.layouts')
            ->setExtra('translation_domain', 'ngbm_admin');

        $layouts
            ->addChild('shared_layouts', ['route' => 'ngbm_admin_shared_layouts_index'])
            ->setLabel('menu.main_menu.shared_layouts')
            ->setExtra('translation_domain', 'ngbm_admin');

        $menu->reorderChildren($menuOrder);
    }
1237968
public function addToMenu(Menu $menu)
    {
        if($this->postTypeID) {
            $data = [
                'menuID' => $menu->menuID,
                'belongsToID' => $this->categoryID,
                'belongsTo' => 'category',
                'params' => $this->menuLinkParameters(),
                'routeName' => 'category.posts'
            ];

            foreach (Language::all() as $language) {
                $data['slug'][$language->slug] = $this->translate($language->slug)->slug;
                $data['label'][$language->slug] = $this->title;
            }

            factory(MenuLink::class)->create($data);
        }

        return $this;
    }
130489
public function addChild(Node $node, $key = null)
    {
        if ($key === null) {
            $this->children[] = $node;
        } else {
            $this->children[ $key ] = $node;
        }

        return $node;
    }
11287
public function &addItem(MenuItem $menu_item)
    {
        $this->items[$menu_item->getName()] = $menu_item;

        return $this->items[$menu_item->getName()];
    }
627733
protected function isOnLastLevelOfMenu(NodeInterface $menuItemNode)
    {
        if ($this->currentLevel >= $this->getMaximumLevels()) {
            return true;
        }

        if (($this->getLastLevel() !== null)) {
            if ($this->getNodeLevelInSite($menuItemNode) >= $this->calculateNodeDepthFromRelativeLevel($this->getLastLevel(), $this->currentNode)) {
                return true;
            }
        }

        return false;
    }
1317105
public function addMenu(string $label, Addon\DropDownMenu $menu, bool $active = false, bool $disabled = false)
    {
        $this->items[] = [
            'label'    => $label, 
            'menu'     => $menu, 
            'active'   => $active, 
            'disabled' => $disabled
        ];
        return $this;
    }
1142001
public function addItem($text, callable $itemCallable, $showItemExtra = false, $disabled = false): MenuBuilder
    {
        $this->callbacks[$this->resolveKey($text)] = $itemCallable;
        return parent::addItem($text, $itemCallable, $showItemExtra);
    }
810633
public function setMenu(MenuNodeInterface $menu = null)
    {
        $this->menu = $menu;

        if ($menu->getNode() !== $this) {
            $menu->setNode($this);
        }

        return $this;
    }
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;
    }
728680
public function addChild(&$node, $setCurrent = false)
	{
		JLog::add('JTree::addChild() is deprecated.', JLog::WARNING, 'deprecated');

		$this->_current->addChild($node);

		if ($setCurrent)
		{
			$this->_current = &$node;
		}
	}
524270
public function setMenuItem(\Amulen\PageBundle\Entity\MenuItem $menuItem = null) {
        $this->menuItem = $menuItem;

        return $this;
    }
173972
def append(self, item):
        
        if self.url:
            raise TypeError('Menu items with URL cannot have childrens')

        # Look for already present common node
        if not item.is_leaf():
            for current_item in self.items:
                if item.name == current_item.name:
                    for children in item.items:
                        current_item.append(children)
                    return

        # First insertion
        self.items.append(item)