sokil/static-menu-bundle

This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

Static menu bundle

0.1.0 2016-08-04 16:10 UTC

This package is auto-updated.

Last update: 2021-05-13 20:44:06 UTC


README

Configure menus in symfony configuration file. This is wrapper over knp-menu-bundle.

Installation

You can install bundle through Composer:

composer require sokil/static-menu-bundle

Add bundle to AppKernel:

<?php

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // required dependencies
            new Knp\Bundle\MenuBundle\KnpMenuBundle(),
            // menu bundle
            new Sokil\StaticMenuBundle\StaticMenuBundle(),
        );
    }
}

Menu configuration

Configure menu in app/config/config.yml

static_menu:
  someMenuName: # set some name to your menu
    childrenAttributes:
      class: nav navbar-nav
    items: # configure items of menu
      - label: menu_tasks
        role: ROLE_TASK_VIEWER # role allowed to see menu
        uri: /#tasks
      - label: menu_contacts
        route: contact_us_index
      - label: menu_new_task
        uri: /#tasks/new
        role: IS_AUTHENTICATED_REMEMBERED
        linkAttributes:
          class: visible-xs

See item options at vendor/knplabs/knp-menu/src/Knp/Menu/Factory/CoreExtension.php.

Menu rendering

KNP menus rendered by calling {{ knp_menu_render('static_menu.someMenuName') }}