2017 © Pedro PelĆ”ez
 

symfony-bundle menu-bundle

This bundle of symfony2

image

baconmanager/menu-bundle

This bundle of symfony2

  • Tuesday, February 21, 2017
  • by adanfm
  • Repository
  • 3 Watchers
  • 0 Stars
  • 805 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 12 % Grown

The README.md

BaconMenuBundle

Codacy Badge Latest Stable Version License SensioLabsInsight, (*1)

Este bundle Ć© responsavel por Customizar a criaĆ§Ć£o de menus do KnpMenuBundle, (*2)

InstalaĆ§Ć£o

Para instalar o bundle basta rodar o seguinte comando abaixo:, (*3)

$ composer require baconmanager/menu-bundle

Agora adicione os seguintes bundles no arquivo AppKernel.php:, (*4)

<?php
// app/AppKernel.php
public function registerBundles()
{
    // ...
    new Knp\Bundle\MenuBundle\KnpMenuBundle(),
    new Bacon\Bundle\MenuBundle\BaconMenuBundle(),
    // ...
}

ConfiguraĆ§Ć£o

Adicionar as configuraƧƵes abaixo no arquivo app/config/config.yml, (*5)

#Menu
knp_menu:
    # use "twig: false" to disable the Twig extension and the TwigRenderer
    twig:
        template: BaconCoreBundle:partial:menu.html.twig
    #  if true, enables the helper for PHP templates
    templating: false
    # the renderer to use, list is also available by default
    default_renderer: twig

Criando um menu

Para criar um novo menu basta criar uma classe no namespace MyBundle/Menu/Builder como no exemplo abaixo:, (*6)

Para versĆ£o symfony =< 2.7, (*7)

<?php
// src/AppBundle/Menu/Builder.php
namespace AppBundle\Menu;

use Knp\Menu\FactoryInterface;
use Symfony\Component\DependencyInjection\ContainerAware;

class Builder extends ContainerAware
{
    public function addMenu(FactoryInterface $factory, array $options)
    {
        $menu = $factory->createItem('root');

        $translate = $this->container->get('translator');

        // Menu Catalog
        $menu->addChild($translate->trans('Category'))->setAttribute('icon', '<i class="fa fa-book"></i>');
        $menu[$translate->trans('Category')]->addChild($translate->trans('List'),array('route' => 'admin_category'));
        $menu[$translate->trans('Category')]->addChild($translate->trans('New'),array('route' => 'admin_category_new'));

        return $menu;
    }
}

Para versĆ£o do symfony >= 2.8, (*8)

<?php
// src/AppBundle/Menu/Builder.php
namespace AppBundle\Menu;

use Knp\Menu\FactoryInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;

class Builder implements ContainerAwareInterface
{
    use ContainerAwareTrait;

    public function addMenu(FactoryInterface $factory, array $options)
    {
        $menu = $factory->createItem('root');

        $translate = $this->container->get('translator');

        // Menu Catalog
        $menu->addChild($translate->trans('Category'))->setAttribute('icon', '<i class="fa fa-book"></i>');
        $menu[$translate->trans('Category')]->addChild($translate->trans('List'),array('route' => 'admin_category'));
        $menu[$translate->trans('Category')]->addChild($translate->trans('New'),array('route' => 'admin_category_new'));

        return $menu;
    }
}

Renderizando o menu no layout(twig):

{{ bacon_menu_full_render() }}

The Versions

21/02 2017

dev-master

9999999-dev

This bundle of symfony2

  Sources   Download

MIT

The Requires

 

by Adan Felipe Medeiros
by Jonas Vieira Pereira
by Mateus Guerra

bundle menu custom knpmenubundle

03/01 2016

v0.1

0.1.0.0

This bundle of symfony2

  Sources   Download

MIT

The Requires

 

by Adan Felipe Medeiros
by Jonas Vieira Pereira
by Mateus Guerra

bundle menu custom knpmenubundle