templates/bundles/EasyAdminBundle/default/menu.html.twig line 1

Open in your IDE?
  1. {% macro render_menu_item(item, translation_domain) %}
  2.     {% if item.type == 'divider' %}
  3.         {{ item.label|trans(domain = translation_domain) }}
  4.     {% else %}
  5.         {% set menu_params = { menuIndex: item.menu_index, submenuIndex: item.submenu_index } %}
  6.         {% set path =
  7.         item.type == 'link' ? item.url :
  8.         item.type == 'route' ? path(item.route, item.params) :
  9.         item.type == 'entity' ? path('easyadmin', { entity: item.entity, action: 'list' }|merge(menu_params)|merge(item.params)) :
  10.         item.type == 'empty' ? '#' : ''
  11.         %}
  12.         {# if the URL generated for the route belongs to the backend, regenerate
  13.            the URL to include the menu_params to display the selected menu item
  14.            (this is checked comparing the beginning of the route URL with the backend homepage URL)
  15.         #}
  16.         {% if item.type == 'route' and (path starts with path('easyadmin')) %}
  17.             {% set path = path(item.route, menu_params|merge(item.params)) %}
  18.         {% endif %}
  19.         <a href="{{ path }}"
  20.            class="{{ item.css_class|default('') }}"
  21.            {% if item.target|default(false) %}target="{{ item.target }}"{% endif %}
  22.                 {% if item.rel|default(false) %}rel="{{ item.rel }}"{% endif %}>
  23.             {% if item.icon is not empty %}<i class="fa fa-fw {{ item.icon }}"></i>{% endif %}
  24.             <span class="menu-title">{{ item.label|trans(domain = translation_domain) }}</span>
  25.             {% if item.children|default([]) is not empty %}<i class="arrow"></i>{% endif %}
  26.         </a>
  27.     {% endif %}
  28. {% endmacro %}
  29. {% import _self as helper %}
  30. {% block main_menu_before %}{% endblock %}
  31. <div id="mainnav-menu-wrap">
  32.     <div class="nano">
  33.         <div class="nano-content">
  34.             {% set _translation_domain = (_entity_config.translation_domain)|default(easyadmin_config('translation_domain'))|default('messages') %}
  35.             <ul id="mainnav-menu" class="list-group">
  36.                 {% set _menu_items = easyadmin_config('design.menu') %}
  37.                 {% block main_menu %}
  38.                     {% for item in _menu_items %}
  39.                         {% block menu_item %}
  40.                             {% set is_selected_menu = app.request.query.get('menuIndex')|default(-1) == item.menu_index %}
  41.                             {% set is_selected_submenu = is_selected_menu and app.request.query.get('submenuIndex')|default(-1) != -1 %}
  42.                             {% if easyadmin_is_granted(item.permission) %}
  43.                                 <li class="{{ item.type == 'divider' ? 'list-header' }} {{ item.children is not empty ? 'treeview' }} {{ is_selected_menu ? 'active' }} {{ is_selected_submenu ? 'submenu-active' }}">
  44.                                     {{ helper.render_menu_item(item, _translation_domain) }}
  45.                                     {% if item.children|default([]) is not empty %}
  46.                                         <ul class="collapse">
  47.                                             {% for subitem in item.children %}
  48.                                                 {% block menu_subitem %}
  49.                                                     {% if easyadmin_is_granted(subitem.permission) %}
  50.                                                         <li class="{{ subitem.type == 'divider' ? 'list-header' }} {{ is_selected_menu and app.request.query.get('submenuIndex')|default(-1) == subitem.submenu_index ? 'active' }}">
  51.                                                             {{ helper.render_menu_item(subitem, _translation_domain) }}
  52.                                                         </li>
  53.                                                     {% endif %}
  54.                                                 {% endblock menu_subitem %}
  55.                                             {% endfor %}
  56.                                         </ul>
  57.                                     {% endif %}
  58.                                 </li>
  59.                             {% endif %}
  60.                         {% endblock menu_item %}
  61.                     {% endfor %}
  62.                 {% endblock main_menu %}
  63.             </ul>
  64.         </div>
  65.     </div>
  66. </div>
  67. {% block main_menu_after %}{% endblock %}