Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KNP menu enabled true not working #184

Open
glerendegui opened this issue Oct 5, 2017 · 3 comments
Open

KNP menu enabled true not working #184

glerendegui opened this issue Oct 5, 2017 · 3 comments

Comments

@glerendegui
Copy link

I'm having a problem with knp_menu.
My config is

avanzu_admin_theme:
    knp_menu:                         # knp menu integration     
        enable         : true 

but when I put {{ dump(avanzu_admin_context.knp_menu) }} on default-layout.html.twig it dumps

array:3 [▼
  "enable" => false
  "main_menu" => "AvanzuAdminThemeBundle:MenuBuilder:createMainMenu"
  "breadcrumb_menu" => false
]

So, knp is never activated.

Also, (maybe this should go on another thread) if I change

enable

default option at ContexHelper.php to true I get

Unknown "knp_menu_render" function at

knp-menu.html.twig at line 2 (knp_menu_render(avanzu_admin_context.knp_menu.main_menu, {)

Maybe I need to install knp bundle?

@shakaran
Copy link
Collaborator

shakaran commented Oct 5, 2017

It seems that the docs needs to be updated to be more clear.

https://github.com/avanzu/AdminThemeBundle/blob/master/Resources/docs/knp_menu.md

Since the use of knp is optional, the package is not installed and "suggested", but I think that it is not detected at any place which is missing when you enable, so you get the ugly error/warning instead a useful message that says that you need install knpmenu

So you need first install with composer:

composer require knplabs/knp-menu-bundle

And you have 2 places where enable.

First it is using in general, which is under:

avanzu_admin_theme:
    knp_menu:                         # knp menu integration     
        enable: true 

But if you use the avanzu_admin_context, it requires enable in the context, which is under the "options" key, that is:

avanzu_admin_theme:
    options:
        knp_menu:                         # knp menu integration     
            enable: true 

So two task to me here:

    1. Detect where the knp-menu is enabled and check if installed for show a better warning
    1. Improve the documentation explaning better how to enable and use in general or context for the theme.

@hounded
Copy link
Contributor

hounded commented Jul 22, 2018

So i'm updating and have built my menu using

avanzu_admin_theme:
    knp_menu:                         # knp menu integration
        enable         : true

and using a service

services:
    orders.knp_menu_listener:
        class: AppBundle\EventListener\ordersKnpMenuListener
        arguments: ['@service_container']
        tags:
            - { name: kernel.event_listener, event: theme.sidebar_setup_knp_menu, method: onSetupKnpMenu}

so this use to work with beta5 but on beta10 this doesn't work no more I still get the same as original question if I dump out knp_menu

array:3 [▼
  "enable" => false
  "main_menu" => "avanzu_main"
  "breadcrumb_menu" => false
]

How can I resolve it so my already created and working menu works?

@hounded
Copy link
Contributor

hounded commented Jul 22, 2018

Ok the following service is not getting picked up, adding it to my services resolved the problem.

    avanzu_admin_theme.knp_menu_builder:
        class: "%avanzu_admin_theme.knp_menu_builder.class%"
        arguments:
            - "@knp_menu.factory"
            - "@avanzu_admin_theme.admin_router"
            - "@event_dispatcher"
        tags:
            - {name: knp_menu.menu_builder, method: createMainMenu, alias: avanzu_main }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants