knpmenubundle

How to avoid “knp_menu.factory” deprecation?

狂风中的少年 提交于 2020-01-07 04:41:08
问题 I'm trying to use KNPMenuBundle with Sumfony 3.3 but I'm getting this annoying warning: Autowiring services based on the types they implement is deprecated since Symfony 3.3 and won't be supported in version 4.0. You should rename (or alias) the "knp_menu.factory" service to "Knp\Menu\FactoryInterface" instead. Trace: {..../vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php:344: } I did not set this knp_menu.factory at all, probably it was automatically

How to exclude certain string from showing up in missing translations using KnpMenuBundle and Symfony3

人走茶凉 提交于 2019-12-24 06:04:57
问题 Introduction In my personal project I am using: XAMPP with PHP v7.1.6 Symfony v3.3.8 KnpMnenuBundle dev-master / 2.2.x-dev ( dev version because it is compatible with current Symfony 3.3.x version, earlier versions did not install via composer .) [link 1], [link 2], [link 3] in order to manage Menus. Bootstrap v3.3.7 Bootstrap and KnpMenuBundle integration [link 4] Setting up To setup i used documentation in [2], [3] and code samples [4]. My menu is working, integration between Bootstrap and

Add Class to knp menu root Element with Twig

北城余情 提交于 2019-12-23 07:07:30
问题 what is the correct way to add a class to knp_menu's root element <ul> with twig? i tried a lot of things: 1. {{ knp_menu_render('main', {'class': 'foo'}) }} 2. {{ knp_menu_render('main', {'attributes': {'class': 'foo'}}) }} 3. {{ knp_menu_render('main', {'listAttributes': {'class': 'foo'}}) }} 4. {{ knp_menu_render('main', {'attributes': {'listAttributes': {'class': 'foo'}}}) }} none of them worked 回答1: You can add it in your menu builder like.. $menu = $this->factory->createItem('root',

Creating breadcrumbs in symfony 2.1 using knpmenu bundle

半腔热情 提交于 2019-12-22 08:12:16
问题 What's the best way to create breadcrumbs using knpmenu bundle in symfony 2.1.x ? Aside from using 3-rd party bundles. UPDATE: Hi, theunraveler , sorry for late answer. Now I've been following your example and I'm stuck at one moment. Here, code below throws an exception, that Missing argument 2 for Acme\DemoBundle\Menu\MenuBuilder::getBreadCrumbs() {% set item = knp_menu_get('main') %} {{ knp_menu_render(item) }} {% block breadcrumbs %} {% set breadcrumbs = knp_menu_get('breadcrumbs', [], {

How to change the “current” class to “active” in KNPMenuBundle

你说的曾经没有我的故事 提交于 2019-12-18 16:09:07
问题 I was wondering, what is the best way to change the "current" class to be "active" so Bootstrap will work correctly with it? I thought about copying and overriding the knp_menu_html.twig but i think its not the best way... Anyway better doing it? 回答1: You can pass it like that: {{ knp_menu_render('AcmeDemoBundle:Builder:mainMenu', {'currentClass': 'active'}) }} 回答2: To apply default options in all your application, you can set the knp_menu.renderer.twig.options parameter like this: // app

Render custom attribute KNP Menu

风流意气都作罢 提交于 2019-12-12 13:19:20
问题 Is there a way to render a custom attribute in the KNP Menu Bundle, something like this: $menu = $factory->createItem(Role::ROLE_PROGRAM_EVENT_PLANNER, array( 'route' => 'show_form_events', 'attributes' => array('class' => 'menu pe_planner'), 'extra' => array( 'content' => 'my custom content' ) )); I have overriden the linkElement by adding an extra div after the a-tag. In that div I would like to render extra content {% block linkElement %} {% import _self as knp_menu %} <a href="{{ item.uri

Symfony 2 breadcrumbs with KnpMenu

蓝咒 提交于 2019-12-11 07:24:39
问题 I use stable versions of KnpMenu and KnpMenuBundle - v.1.2.0 I can't use v.2, because of some dependencies. And I'm trying to build breadcrumbs, depending on my menu. Let's start with menu. I have my MenuBuilder class: $menu = $this->factory->createItem('main'); $menu->setLabel('Main'); $menu->addChild('home', array('route' => 'home','label'=>'Home')); $menu['home']->addChild('level1',array('route' => 'level1', 'label' => 'Level1')); $menu['home']['level1']->addChild('level2',array('route' =>

Symfony2 KnpMenuBundle: set active a menu item even when its not on that menu

余生颓废 提交于 2019-12-10 14:00:04
问题 I created my menu builder and it works. One of my route is /database But this has a child route: database/view/{id} I don't want to put the view route into the menu items because without the ID it won't work. But I want the database route to be active when the user is on the view. How can I do this? 回答1: Managed to solve it with this little hack: in the menuBuider after you add all the Children but before you return the menu i added $request = $this->container->get('request'); $routeName =

symfony2.1 bundle version confusion, for symfony and sonata admin / knp menu bundle

谁说我不能喝 提交于 2019-12-07 03:45:03
问题 I want to use symfony2.1 for a new project. I try to install symfony2 with composer. But there were multiple errors/problems and so I have also questions for each problem in bold font style . Sometimes I don't know if I do it the right way. I want to use a stable version so I chosen the 2.1.0 version and not the dev/master. php composer.phar create-project symfony/framework-standard-edition symfony v2.1.0 the result was this: Installing symfony/framework-standard-edition (v2.1.0) - Installing

How to disable HTML escaping of labels in KnpMenuBundle

℡╲_俬逩灬. 提交于 2019-12-05 15:02:32
问题 I want to render an HTML label like: $menu->addChild('Dashboard', array( 'route' => 'dashboard', 'label' => '<i class="fa-icon-bar-chart"></i><span class="hidden-tablet"> Dashboard</span></a>', 'extra' => array('safe_label' => true) ) ); And I've pass the proper option while rendering: {{ knp_menu_render('WshCmsHtmlBundle:Builder:mainMenu', {'allow_safe_labels': true} ) }} But my label is still being escaped. What am I doing wrong? 回答1: Ok, the answer is! You set up extra items on menu item