public function createMainMenu(Request $request)
    {
        $menu = $this->factory->createItem('root');
        $menu->setChildrenAttribute('id', 'nav'); // needed for bootstrap

        // Add dashboard first
        $menu->addChild(
            'Dashboard',
            array(
                'route' => 'serius_admin_dashboard_index',
                'labelAttributes' => array(
                    'class' => 'fa fa-home'     // icon for dashboard
                ),
            )
        );

        // Add Sonata Admin menu items
        foreach ($this->adminPool->getDashboardGroups() as $group) {

            // Do not display the group label if no item in group is available
            $count = 0;

            /**
             * @var $admin \Sonata\AdminBundle\Admin\Admin
             */
            foreach ($group['items'] as $admin) {
                if ($admin->hasRoute('list')) {
                    $count++;
                }
            }

            if ($count == 1) {
                // If one item, add first as menu item
                $admin = $group['items'][0];
                $item = $this->addAdmin($menu, $admin, $request, $group);

                $item->setLabelAttributes(array(
                    'class' => $group['icon'] ?: 'fa fa-folder',
                ));
            } elseif ($count > 1) {
                // If more items, add as submenu item

                $label = $group['label'];
                if ($group['label_catalogue']) {
                    $label = $this->translator->trans($label, array(), $group['label_catalogue']);
                }

                $groupItem = $menu->addChild($label, array(
                    'uri' => '#',
                    'labelAttributes' => array(
                        'class' => $group['icon'] ?: 'fa fa-folder',
                    ),
                ));

                foreach ($group['items'] as $admin) {
                    $this->addAdmin($groupItem, $admin, $request, $group);
                }
            }
        }

        return $menu;
    }
public function createMainMenu(Request $request)
    {
        $menu = $this->factory->createItem('root');
        $menu->setChildrenAttribute('id', 'nav'); // needed for bootstrap

        // Add dashboard first
        $menu->addChild(
            'Dashboard',
            array(
                'route' => 'serius_admin_dashboard_index',
                'labelAttributes' => array(
                    'class' => 'fa fa-home'     // icon for dashboard
                ),
            )
        );

        // Add Sonata Admin menu items
        foreach ($this->adminPool->getDashboardGroups() as $group) {

            // Do not display the group label if no item in group is available
            $count = 0;

            /**
             * @var $admin \Sonata\AdminBundle\Admin\Admin
             */
            foreach ($group['items'] as $admin) {
                if ($admin->hasRoute('list')) {
                    $count++;
                }
            }

            if ($count == 1) {
                // If one item, add first as menu item
                $admin = $group['items'][0];
                $item = $this->addAdmin($menu, $admin, $request, $group);

                $item->setLabelAttributes(array(
                    'class' => $group['icon'] ?: 'fa fa-folder',
                ));
            } elseif ($count > 1) {
                // If more items, add as submenu item

                $label = $group['label'];
                if ($group['label_catalogue']) {
                    $label = $this->translator->trans($label, array(), $group['label_catalogue']);
                }

                $groupItem = $menu->addChild($label, array(
                    'uri' => '#',
                    'labelAttributes' => array(
                        'class' => $group['icon'] ?: 'fa fa-folder',
                    ),
                ));

                foreach ($group['items'] as $admin) {
                    $this->addAdmin($groupItem, $admin, $request, $group);
                }
            }
        }

        return $menu;
    }
public function createMainMenu ( Request $ request ) { $ menu = $ this -> factory -> createItem ( 'root' ) ; $ menu -> setChildrenAttribute ( 'id' , 'nav' ) ; // needed for bootstrap // Add dashboard first $ menu -> addChild ( 'Dashboard' , array ( 'route' => 'serius_admin_dashboard_index' , 'labelAttributes' => array ( 'class' => 'fa fa-home' // icon for dashboard ) , ) ) ; // Add Sonata Admin menu items foreach ( $ this -> adminPool -> getDashboardGroups ( ) as $ group ) { // Do not display the group label if no item in group is available $ count = 0 ; /**
             * @var $admin \Sonata\AdminBundle\Admin\Admin
             */ foreach ( $ group [ 'items' ] as $ admin ) { if ( $ admin -> hasRoute ( 'list' ) ) { $ count ++ ; } } if ( $ count == 1 ) { // If one item, add first as menu item $ admin = $ group [ 'items' ] [ 0 ] ; $ item = $ this -> addAdmin ( $ menu , $ admin , $ request , $ group ) ; $ item -> setLabelAttributes ( array ( 'class' => $ group [ 'icon' ] ? : 'fa fa-folder' , ) ) ; } elseif ( $ count > 1 ) { // If more items, add as submenu item $ label = $ group [ 'label' ] ; if ( $ group [ 'label_catalogue' ] ) { $ label = $ this -> translator -> trans ( $ label , array ( ) , $ group [ 'label_catalogue' ] ) ; } $ groupItem = $ menu -> addChild ( $ label , array ( 'uri' => '#' , 'labelAttributes' => array ( 'class' => $ group [ 'icon' ] ? : 'fa fa-folder' , ) , ) ) ; foreach ( $ group [ 'items' ] as $ admin ) { $ this -> addAdmin ( $ groupItem , $ admin , $ request , $ group ) ; } } } return $ menu ; }
Creates the main menu

@param Request $request

@return ItemInterface
Creates the main menu