{% extends 'knp_menu.html.twig' %} {% block root %} {%- set listAttributes = item.childrenAttributes|merge({'class': 'sidebar-menu'}) %} {%- set request = item.getExtra('request') %} {{ block('list') -}} {% endblock %} {% block item %} {%- if item.displayed %} {#- check role of the group #} {%- set display = (item.getExtra('roles') is empty or is_granted('ROLE_SUPER_ADMIN') ) %} {%- for role in item.getExtra('roles') if not display %} {%- set display = is_granted(role) %} {%- endfor %} {%- endif %} {%- if item.displayed and display|default %} {%- set active = false %} {%- if item.getExtra('active') is not empty and item.getExtra('active') %} {%- set active = true %} {%- elseif item.getExtra('admin') is not empty and item.getExtra('admin').hasroute('list') and item.getExtra('admin').isGranted('LIST') and request.get('_sonata_admin') == item.getExtra('admin').code %} {%- set active = true %} {%- elseif item.route is defined and request.get('_route') == item.route %} {%- set active = true %} {%- else %} {%- for child in item.children if not active %} {%- if child.getExtra('admin') is not empty and child.getExtra('admin').hasroute('list') and child.getExtra('admin').isGranted('LIST') and request.get('_sonata_admin') == child.getExtra('admin').code %} {%- set active = true %} {%- elseif child.route is defined and request.get('_route') == child.route %} {%- set active = true %} {%- endif %} {%- endfor %} {%- endif %} {%- if item.hasChildren %} {%- do item.setAttribute('class', (item.attribute('class')~' treeview')|trim) %} {%- endif %} {%- if active %} {%- do item.setAttribute('class', (item.attribute('class')~' active')|trim) %} {%- do item.setChildrenAttribute('class', (item.childrenAttribute('class')~' active')|trim) %} {%- endif %} {%- do item.setChildrenAttribute('class', (item.childrenAttribute('class')~' treeview-menu')|trim) %} {{ parent() }} {% endif %} {% endblock %} {% block linkElement %} {% spaceless %} {% set translation_domain = item.getExtra('translationdomain', 'messages') %} {% set icon = item.attribute('icon') ? item.attribute('icon') : (item.level > 1 ? '' : '') %} {% set is_link = true %} {{ parent() }} {% endspaceless %} {% endblock %} {% block spanElement %} {% spaceless %} {% set translation_domain = item.attribute('label_catalogue') %} {% set icon = item.attribute('icon')|default ? item.attribute('icon') : '' %} {{ icon|default|raw }} {{ parent() }} {% endspaceless %} {% endblock %} {% block label %}{% if is_link is defined and is_link %}{{ icon|default|raw }}{% endif %}{% if options.allow_safe_labels and item.getExtra('safe_label', false) %}{{ item.label|raw }}{% else %}{{ item.label|trans({}, translation_domain|default('messages')) }}{% endif %}{% endblock %}