简体   繁体   English

菜单中的Sonata Admin自定义控制器覆盖现有控制器

[英]Sonata Admin Custom Controller in Menu Override existing ones

I try to add a custom Controller/Page to the Knp Menu in Sonata Admin. 我尝试在Sonata Admin的Knp菜单中添加自定义的Controller / Page。 I have bring it allready to work that the menu shows me the link in the navigation. 我已经准备好工作,菜单显示了导航中的链接。 I do it like this in the config: 我在配置中这样做:

    groups:
             User:
                  label:            User
                  items:
                      - route:        user_index
                        label:        User Profile
                      - route:        user_edit
                        label:        User Edit
                      - route:        user_password
                        label:        User Password
                  roles: [ ROLE_USER]

My Problem is my existing Sonata Admin Controllers are not shown in the menu when i activate this setting. 我的问题是,当我激活此设置时,菜单中未显示我现有的Sonata Admin Controller。 What can i do to add and not override? 我该怎么做才能添加而不是覆盖? What i found is to maybe register a listener and extend there the menu. 我发现的是也许要注册一个侦听器并在那里扩展菜单。 But i found it must be easier than that. 但是我发现它一定比这更容易。

What is the best way to do this? 做这个的最好方式是什么? THX 谢谢

I had the same problem and I solved it by adding an empty menu item with the same label as the default Sonata items (in my situation that group was called admin ): 我遇到了同样的问题,并通过添加一个空菜单项来解决此问题,该菜单项的标签与默认奏鸣曲项相同(在我的情况下,该组称为admin ):

sonata_admin:
    templates:
        # default global templates
        layout: SonataAdminBundle::layout.html.twig
    dashboard:
        groups:
            admin: ~
            User:
                label:            User
                items:
                    - route:        user_index
                      label:        User Profile
                    - route:        user_edit
                      label:        User Edit
                    - route:        user_password
                      label:        User Password
                roles: [ ROLE_USER]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM