src/Menu/MenuBuilder.php
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;
    }
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;
    }
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 ; }
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
Add a menu item node at the correct place in the menu .