PHP code example of eschmar / menu-bundle

1. Go to this page and download the library: Download eschmar/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/ */

    

eschmar / menu-bundle example snippets


namespace App\Menu;

use Eschmar\MenuBundle\Menu\AbstractMenu;

class TestMenu extends AbstractMenu
{
    public function generateMenu()
    {
        // create root node
        $this->root = $this->newNode('Navigation');

        // append a new node for each navigation element
        $this->root->node('Link 1');
        $this->root->node('Link 2');
        $this->root->node('Link 3');

        // multi-dimensional
        $this->root['Link 2']->node('Sublink 1');
        $this->root['Link 2']['Sublink 1']->node('Subsublink 1');

        // generate route
        $this->root['Link 3']->node('Sublink 3', null, 'acme_hello_homepage');

        // role permissions
        $this->root['Link 3']->node('Sublink 2', null, null, 'ROLE_ADMIN', array());
    }

} // END class TestMenu