sonata_menu.html.twig 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. {% extends 'knp_menu.html.twig' %}
  2. {% block root %}
  3. {%- set listAttributes = item.childrenAttributes|merge({'class': 'sidebar-menu'}) %}
  4. {%- set request = item.extra('request') ?: app.request %}
  5. {{ block('list') -}}
  6. {% endblock %}
  7. {% block item %}
  8. {%- if item.displayed %}
  9. {#- check role of the group #}
  10. {%- set display = (item.extra('roles') is empty or is_granted('ROLE_SUPER_ADMIN') ) %}
  11. {%- for role in item.extra('roles') if not display %}
  12. {%- set display = is_granted(role) %}
  13. {%- endfor %}
  14. {%- endif %}
  15. {%- if item.displayed and display|default %}
  16. {% set options = options|merge({branch_class: 'treeview', currentClass: "active"}) %}
  17. {%- do item.setChildrenAttribute('class', (item.childrenAttribute('class')~' active')|trim) %}
  18. {%- do item.setChildrenAttribute('class', (item.childrenAttribute('class')~' treeview-menu')|trim) %}
  19. {{ parent() }}
  20. {% endif %}
  21. {% endblock %}
  22. {% block linkElement %}
  23. {% spaceless %}
  24. {% set translation_domain = item.extra('label_catalogue', 'messages') %}
  25. {% if item.extra('on_top') is defined and not item.extra('on_top') %}
  26. {% set icon = item.extra('icon')|default(item.level > 1 ? '<i class="fa fa-angle-double-right" aria-hidden="true"></i>' : '') %}
  27. {% else %}
  28. {% set icon = item.extra('icon') %}
  29. {% endif %}
  30. {% set is_link = true %}
  31. {{ parent() }}
  32. {% endspaceless %}
  33. {% endblock %}
  34. {% block spanElement %}
  35. {% spaceless %}
  36. <a href="#">
  37. {% set translation_domain = item.extra('label_catalogue') %}
  38. {% set icon = item.extra('icon')|default('') %}
  39. {{ icon|raw }}
  40. {{ parent() }}
  41. {%- if item.extra('keep_open') is not defined or not item.extra('keep_open') -%}
  42. <span class="pull-right-container"><i class="fa pull-right fa-angle-left"></i></span>
  43. {%- endif -%}
  44. </a>
  45. {% endspaceless %}
  46. {% endblock %}
  47. {% block label %}{% if is_link is defined and is_link %}{{ icon|default|raw }}{% endif %}{% if options.allow_safe_labels and item.extra('safe_label', false) %}{{ item.label|raw }}{% else %}{{ item.label|trans({}, translation_domain|default('messages')) }}{% endif %}{% endblock %}