PHP code example of desarrolla2 / menu-bundle

1. Go to this page and download the library: Download desarrolla2/menu-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

desarrolla2 / menu-bundle example snippets


// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new Knp\Bundle\Desarrolla2\MenuBundle(),
        );

        // ...
    }

    // ...
}




namespace AdminBundle\Menu;

use Desarrolla2\MenuBundle\Menu\MenuInterface;

class MainMenu implements MenuInterface
{
    public function getMenu()
    {
        return [
            'class' => 'sidebar-menu',
            'items' => [
                [
                    'name' => 'Users',
                    'icon' => 'fa fa-user',
                    'items' => [
                        [
                            'name' => 'Admins',
                            'route' => 'admin_core_user_admin_list',
                            'active_routes' => [
                                'admin_core_user_admin_[\w]+',
                            ],
                        ],
                        [
                            'name' => 'Clients',
                            'route' => 'admin_core_user_client_list',
                            'active_routes' => [
                                'admin_core_user_client_[\w]+',
                            ],
                        ],
                    ],
                ],                
                [
                    'name' => 'Groups',
                    'route' => 'admin_core_group_list',
                    'icon' => 'fa fa-users',
                    'active_routes' => [
                        'admin_core_group_[\w]+',
                        '_admin.group.[\w\.]',
                    ],
                ],
            ],
        ];
    }
}