Download the PHP package wemakecustom/menu-part-bundle without Composer
On this page you can find all versions of the php package wemakecustom/menu-part-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wemakecustom/menu-part-bundle
More information about wemakecustom/menu-part-bundle
Files in wemakecustom/menu-part-bundle
Package menu-part-bundle
Short Description Symfony Bundle wrapping KnpMenuBundle to declare menus by small parts
License MIT
Homepage https://github.com/wemakecustom/menu-part-bundle
Informations about the package menu-part-bundle
WMCMenuPartBundle
Wrapper around knplabs/knp-menu-bundle
to easily create partial self contained menu providers.
The goal is to create global menus (main, top, sidebar, etc.) and have different services fill them when they see fit. An example would be a sidebar that offers actions (edit, delete, etc.) on the current resource.
This bundle really needs tests though…
WARNING: This bundles requries KnpMenuBundle ~2.0.
Installation
Download and install the bundle via composer
Enable the Bundle (and its dependencies) in the Kernel:
Creating your first menu
Using JMSDiExtraBundle
,
you can simply create a class that extends MenuPartInterface
:
Notice the menu
attribute set to user
, this is mandatory.
You can create multiple MenuPartInterface
with the same menu name and they will
concatenante themselves. You can also use the priority
tag attribute to modify the order.
This is a service, so inject whatever you need: request_stack
, security.authorization_checker
, etc.
If you are not using JMSDiExtraBundle
, you can of course
use the traditional way. See menu.yml
Integration in template
Simply knp_menu_render
in your template with the name of your menu.
Configuration
Out of the box, the bundle does not require any configuration.
When you create MenuPartInterface
, a menu will automatically be created with default options.
You can however specify additional options in the general bundle configuration:
Provided Visitors
Security filter
This filter (service name: wmc.menu_part.filter.security
) will hide items the
current user isn't allowed to access.
The current version of this filter relies only on the firewall and doesn't check
the @Security
annotations. (TODO)
Localization (L10n) visitor
You first need to enable the visitor for the menus you want to translate.
The following example enable the visitor for all menus:
This visitor will call the translator
service on every menu item. The visitor
can be disabled for choosen items by setting the translation_parameters
extra to false
.
To specify a custom translation domain, you can use the translation_domain
extra.
If transChoice
is to be used, specify the translation_number
extra.
The item's label will be used as translation key.
Example:
Provided Voters
Voters are used to detect the current item(s) in the menu.
See voters.yml
on how to use RequestVoter
and PrefixVoter
. The file can also be imported as-is in
app/config/config.yml
.
Author
All versions of menu-part-bundle with dependencies
symfony/framework-bundle Version ^2.1|^3.0
knplabs/knp-menu-bundle Version ~2.0