定制 famelo/navigation 二次开发

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

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

famelo/navigation

Composer 安装命令:

composer require famelo/navigation

包简介

README 文档

README

This package uses a combination of Routes.yaml and Policy.yaml to generate a menu for you :)

-
  name: 'Home'
  uriPattern: 'home'
  navigation: 'Home'
  defaults:
    '@format': 'html'
    '@action':     'index'
    '@controller': 'Standard'
    '@package': 'My.Package'
  appendExceedingArguments: true

-
  name: 'Products'
  uriPattern: 'products'
  navigation: 'Products'
  defaults:
    '@format': 'html'
    '@action':     'index'
    '@controller': 'Products'
    '@package': 'My.Package'
  appendExceedingArguments: true

-
  name: 'Product in Foo Category'
  uriPattern: 'products/foo'
  navigation: 'Foo'
  defaults:
    '@format': 'html'
    '@action':     'foo'
    '@controller': 'Products'
    '@package': 'My.Package'
  appendExceedingArguments: true

That routes will be parsed based on the paths into:

Home
Products
  - Foo

Now let's render a menu from that information:

{namespace n=Famelo\Navigation\ViewHelpers}
<ul class="navigation">
<n:navigation as="items">
<f:for each="{items}" as="item">
  <li>
      <n:action actionConfiguration="{item}">{item.label}</n:action>
      <f:if condition="{item.children}">
        <ul>
        <f:for each="{item.children}" as="child">
          <li>
              <n:action actionConfiguration="{child}">{child.label}</n:action>
          </li>
        </f:for>
        </ul>
      </f:if>
  </li>
</f:for>
</n:navigation>
</ul>

Something you don't see, which happens in the background is, that each NavigationItem is checked through the Policy.yaml if the current user has access to it. So, if you add a Policy.yaml like this:

resources:
  methods:
    Products: 'method(My\Package\Controller\ProductsController->.*Action())'

roles:
  Administrator: []

acls:
  Administrator:
    methods:
      Products: GRANT

Only the Logged in Administrator will see the Products NavigationItems :)

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2012-11-30