{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #} {% set main_menu_contents %} {% block main_menu_before %}{% endblock %} {% block main_menu %} {# the main menu is a flat list of items where 'section' items mark the start of a new group #} {% set menu_groups = [] %} {% set current_group = {section: null, items: []} %} {% for menuItem in ea().mainMenu.items %} {% if menuItem.isMenuSection %} {% if current_group.section is not null or current_group.items is not empty %} {% set menu_groups = menu_groups|merge([current_group]) %} {% endif %} {% set current_group = {section: menuItem, items: []} %} {% else %} {# a submenu can be empty when its items define permissions and the current user can't see any of them; in that case, don't display anything for the submenu #} {% set is_submenu_item_with_no_items = menuItem.type == constant('EasyCorp\\Bundle\\EasyAdminBundle\\Dto\\MenuItemDto::TYPE_SUBMENU') and not menuItem.hasSubItems %} {% if not is_submenu_item_with_no_items %} {% set current_group = current_group|merge({items: current_group.items|merge([menuItem])}) %} {% endif %} {% endif %} {% endfor %} {% if current_group.section is not null or current_group.items is not empty %} {% set menu_groups = menu_groups|merge([current_group]) %} {% endif %} {# badges and submenus are rendered into variables before calling the components because macros (and other template-level constructs) are not available inside the component slots, which are compiled as separate templates #} {% for menu_group in menu_groups %} {% set group_items %} {% for menuItem in menu_group.items %} {% set item_badge %} {%- if menuItem.hasVisibleBadge -%} {{ _self.render_menu_badge(menuItem.badge) }} {%- endif -%} {% endset %} {% set item_submenu %} {% if menuItem.hasSubItems %} {% set submenu_items %} {% for menuSubItem in menuItem.subItems %} {% if menuSubItem.isMenuSection %}