src/Zicht/Bundle/MenuBundle/Menu/Builder.php
public function addMenuItem(Request $request, array $item, MenuItem $menu)
    {
        $attributes = array();

        // if the menu item has a name, add it as a css class.
        if ($name = $item['name']) {
            $attributes['class'] = $name;
        }
        if (empty($item['path'])) {
            $uri = null;
        } elseif (preg_match('!^(?:https?://|mailto:)!', $item['path'])) {
            $uri = $item['path'];
        } else {
            $baseUrl = $request->getBaseUrl();
            $uri = $baseUrl . '/' . ltrim($item['path'], '/');
        }

        $menuItem = $menu->addChild(
            $item['id'],
            array(
                'uri' => $uri,
                'attributes' => $attributes,
                'label' => $item['title']
            )
        );

        if (!empty($item['json_data'])) {
            $item['json_data'] = @json_decode($item['json_data']);
        }

        $menuItem->setExtras($item);
        return $menuItem;
    }
public function addMenuItem(Request $request, array $item, MenuItem $menu)
    {
        $attributes = array();

        // if the menu item has a name, add it as a css class.
        if ($name = $item['name']) {
            $attributes['class'] = $name;
        }
        if (empty($item['path'])) {
            $uri = null;
        } elseif (preg_match('!^(?:https?://|mailto:)!', $item['path'])) {
            $uri = $item['path'];
        } else {
            $baseUrl = $request->getBaseUrl();
            $uri = $baseUrl . '/' . ltrim($item['path'], '/');
        }

        $menuItem = $menu->addChild(
            $item['id'],
            array(
                'uri' => $uri,
                'attributes' => $attributes,
                'label' => $item['title']
            )
        );

        if (!empty($item['json_data'])) {
            $item['json_data'] = @json_decode($item['json_data']);
        }

        $menuItem->setExtras($item);
        return $menuItem;
    }
public function addMenuItem ( Request $ request , array $ item , MenuItem $ menu ) { $ attributes = array ( ) ; // if the menu item has a name, add it as a css class. if ( $ name = $ item [ 'name' ] ) { $ attributes [ 'class' ] = $ name ; } if ( empty ( $ item [ 'path' ] ) ) { $ uri = null ; } elseif ( preg_match ( '!^(?:https?://|mailto:)!' , $ item [ 'path' ] ) ) { $ uri = $ item [ 'path' ] ; } else { $ baseUrl = $ request -> getBaseUrl ( ) ; $ uri = $ baseUrl . '/' . ltrim ( $ item [ 'path' ] , '/' ) ; } $ menuItem = $ menu -> addChild ( $ item [ 'id' ] , array ( 'uri' => $ uri , 'attributes' => $ attributes , 'label' => $ item [ 'title' ] ) ) ; if ( ! empty ( $ item [ 'json_data' ] ) ) { $ item [ 'json_data' ] = @ json_decode ( $ item [ 'json_data' ] ) ; } $ menuItem -> setExtras ( $ item ) ; return $ menuItem ; }
Utility method to convert MenuItem's from the doctrine model to Knp MenuItems

@param \Symfony\Component\HttpFoundation\Request $request
@param array $item
@param MenuItem $menu

@return ItemInterface
Utility method to convert MenuItem s from the doctrine model to Knp MenuItems