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
其他信息
- 授权协议: Unknown
- 更新时间: 2012-11-30