定制 desarrolla2/menu-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

desarrolla2/menu-bundle

最新稳定版本:1.0.0

Composer 安装命令:

composer require desarrolla2/menu-bundle

包简介

This bundle provides a menu bundle for symfony2

README 文档

README

The MenuBundle means easy-to-implement and feature-rich menus in your Symfony application!

Installation

Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

$ composer require desarrolla2/menu-bundle

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Enable the Bundle

Then, enable the bundle by adding the following line in the app/AppKernel.php file of your project:

// app/AppKernel.php

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

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

        // ...
    }

    // ...
}

Create your first menu

An example builder class would look like this:

<?php

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\.]',
                    ],
                ],
            ],
        ];
    }
}

Render

To actually render the menu, just do the following from anywhere in any template:

{{ renderMenu('TeacherBundle\\Menu\\MainMenu','sidebar') }}

If you are defined your menu as a service, you can render as follow:

{{ renderMenu('my.menu.service.name','sidebar') }}

统计信息

  • 总下载量: 19.76k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 3
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-02-25