templates/sonata/custom_knp_menu.html.twig line 1

Open in your IDE?
  1. {% extends 'knp_menu.html.twig' %}
  2. {% block root %}
  3.     {%- set listAttributes = item.childrenAttributes|merge({'class': 'sidebar-menu', 'data-widget': 'tree'}) %}
  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) %}
  11.         {% if item.extra('roles') is not empty and item.extra('roles')|length %}
  12.             {% for role in item.extra('roles') %}
  13.                 {% if not display %}
  14.                     {% set display = role in app.user.roles %}
  15.                 {% endif %}
  16.             {% endfor %}
  17.         {% endif %}
  18.         {#- start of new block #}
  19.         {% if display|default %}
  20.             {% set options = options|merge({branch_class: 'treeview', currentClass: "active", ancestorClass: "active"}) %}
  21.             {% do item.setChildrenAttribute('class', (item.childrenAttribute('class')~' active')|trim) %}
  22.             {% do item.setChildrenAttribute('class', (item.childrenAttribute('class')~' treeview-menu')|trim) %}
  23.             {{ parent() }}
  24.         {% endif %}
  25.         {#- end of new block #}
  26.     {% endif %}
  27. {% endblock %}
  28. {% block linkElement %}
  29.         {% set translation_domain = item.extra('label_catalogue', 'messages') %}
  30.         {% if item.extra('on_top') is defined and not item.extra('on_top') %}
  31.             {% set icon = item.extra('icon')|default(item.level > 1 ? '<i class="fa fa-angle-double-right" aria-hidden="true"></i>' : '') %}
  32.         {% else %}
  33.             {% set icon = item.extra('icon') %}
  34.         {% endif %}
  35.         {% set is_link = true %}
  36.         {% import "knp_menu.html.twig" as macros %}
  37.         <a href="{{ item.uri }}"{{ macros.attributes(item.linkAttributes) }}>
  38.             {% if item.attribute('icon') is not empty %}
  39.                 {{ item.attribute('icon')|parse_icon }}
  40.             {% endif %}
  41.             {{ block('label') }}
  42.         </a>
  43. {% endblock %}
  44. {% block spanElement %}
  45.         <a href="#">
  46.             {% set translation_domain = item.extra('label_catalogue') %}
  47.             {% set icon = item.extra('icon')|default('') %}
  48.             {{ icon|raw }}
  49.             {{ parent() }}
  50.             {%- if item.extra('keep_open') is not defined or not item.extra('keep_open') -%}
  51.                 <span class="pull-right-container"><i class="fa pull-right fa-angle-left"></i></span>
  52.             {%- endif -%}
  53.         </a>
  54. {% endblock %}
  55. {% block label %}
  56.     {% if is_link is defined and is_link %}
  57.         {{ icon|default|raw }}
  58.     {% endif %}
  59.     {% if options.allow_safe_labels and item.extra('safe_label', false) %}
  60.         {{ item.label|raw }}
  61.     {% else %}
  62.         {{ item.label|trans({}, translation_domain|default('messages')) }}
  63.     {% endif %}
  64.     {% if item.extras['routes'] is defined %}
  65.         {% if item.extras['routes'][0]['route'] == 'admin_app_programme_suppresion_demande_list' %}
  66.             {% set countDemandeSupp = dashboard_countDemandesSuppression() %}
  67.             {% if countDemandeSupp > 0 %}
  68.                 <div><span class="pastille-notif">{{ countDemandeSupp }}</span></div>
  69.             {% endif %}
  70.         {% endif %}
  71.     {% endif %}
  72. {% endblock %}