从 2.2 版开始,这是一个安全问题。一旦按照文档说明进行了配置,菜单就会正确显示。
更新:ROLE_SONATA_ADMIN
此外,根据changelog 上的 2012-06-05 条目,用户必须具有角色。
如果你想在不这样做的情况下对其进行测试,你可以根据这个文件设置一个新的布局模板: https ://github.com/sonata-project/SonataAdminBundle/blob/master/Resources/views/standard_layout.html.twig ,但注释一些与块中的菜单绘图相关的行sonata_top_bar_nav
,如下所示:
{% block sonata_top_bar_nav %}
{#% if app.security.token and is_granted('ROLE_SONATA_ADMIN') %#}
{% for group in admin_pool.dashboardgroups %}
{% set display = (group.roles is empty or is_granted('ROLE_SUPER_ADMIN') ) %}
{% for role in group.roles if not display %}
{% set display = is_granted(role) %}
{% endfor %}
{# Do not display the group label if no item in group is available #}
{% set item_count = 0 %}
{% if display %}
{% for admin in group.items if item_count == 0 %}
{% if admin.hasroute('list') and admin.isGranted('LIST') %}
{% set item_count = item_count+1 %}
{% endif %}
{% endfor %}
{% endif %}
{#% if display and (item_count > 0) %#}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ group.label|trans({}, group.label_catalogue) }} <span class="caret"></span></a>
<ul class="dropdown-menu">
{% for admin in group.items %}
{#% if admin.hasroute('list') and admin.isGranted('LIST') %#}
<li><a href="{{ admin.generateUrl('list')}}">{{ admin.label|trans({}, admin.translationdomain) }}</a></li>
{#% endif %#}
{% endfor %}
</ul>
</li>
{# % endif %#}
{% endfor %}
{#% endif %#}
{% endblock %}