src/Menu/MenuBuilder.php
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;
    }
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;
    }
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 ; }
Create an new node using the ContentRoute object to generate the uri.

@param \Networking\InitCmsBundle\Entity\MenuItem $menuItem

@return \Knp\Menu\ItemInterface
Create an new node using the ContentRoute object to generate the uri .