boltconcepts/bdev-routing-extra-bundle

扩展Symfony2,提供基于额外路由配置的上下文、面包屑、菜单等功能。

dev-master 2013-03-07 15:04 UTC

This package is not auto-updated.

Last update: 2024-09-14 14:12:21 UTC


README

BDevRoutingExtraBundle 是一种简单的方法,可以将路由信息添加到您的 Symfony2 应用程序中。例如,您可以使用 {{ route_extra('title') }} 来避免在每个模板中覆盖标题块。您还可以使用它来生成面包屑使用 '{{ route_breadcrumb() }}' 或向菜单添加项。

Build Status

安装

步骤 1) 获取包

Composer

"require" :  {
    // ...
    "bdev/bdev-routing-extra-bundle":"dev-master",
}

步骤 2) 注册包

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new BDev\Bundle\RoutingExtraBundle\BDevRoutingExtraBundle(),
    );
    // ...
}

步骤 2) 配置包

# app/config/config.yml
bdev_routing_extra:
    resource: %kernel.root_dir%/config/routing.ext.yml #
    twig: true # use "twig: false" to disable the Twig extension
    breadcrumb: # enable the breadcrumb twig extension (for this twig must be enabled)
        label_attr: [breadcrumb, title] # This a a array that references to the options set per route
    knp_menu: # set knp menu bundle extension
      menus: # define the menu's and there specific options
        name:
          children_attributes:
            class: 'mymain_menu'
# app/config/routing.ext.yml
myBundle: # import route extra's
    resource: "@MyBundle/Resources/config/routing.ext.yml"

home: # the route name and it's options
  title: Home
  summary: Welcome home
  menu: # add the route to a menu
    main:
      attributes:
        class: home
    footer: ~

profile:
  parent: home # the parent route name
  title: Profile
  summary: Your information
  menu:
    footer: ~

待办事项

  • 改进使用文档
  • 使用上下文配置来仅缓存所需的内容
  • 添加 i18n 支持
  • 添加一种方法来排序 KnpMenu 项
  • 为 KnpMenu 代码添加单元测试
  • 通过使用库或扩展当前代码来支持多次渲染来改进面包屑?
  • 将 KnpMenu 代码移至单独的包?
  • 添加安全扩展?