Creating your first menu

Let's see how to create a bootstrap style menu. The menu feature of MopaBootstrapBundle is totally handled by KnpMenuBundle. Here are the required steps to create a menu:

  1. Go to your AppBundle and create a new folder called Menu.
  2. Add a new class and name it Builder.php; the contents of this class should be as follows:
    <?php // mava/src/AppBundle/Menu/Builder.php namespace Mava\CoreBundle\Menu; use Knp\Menu\FactoryInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; class Builder extends ContainerBuilder { public function topMenu(FactoryInterface $factory, array $options) { $menu = $factory->createItem('root'); $menu->setChildrenAttribute('class', 'nav navbar-top-links navbar-right'); $dropdown2 = $menu->addChild(' ...

Get Mastering Symfony now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.