templates/menu.html.twig line 1

Open in your IDE?
  1. {% trans_default_domain "base" %}
  2. <div class="justify-content-center d-flex">
  3.     <div class="main-menu">
  4.         {% if app.user %}
  5.             <div class="title">
  6.                 {{ app.user.username }}
  7.             </div>
  8.             <p class="text-muted mb-3">
  9.                 ROLE_USER
  10.                 {# Проще всем написать так, чтобы никто не ругался {{ app.user.roles|filter(role => role != 'ROLE_USER')|join(', ') }} #}
  11.             </p>
  12.         {% endif %}
  13.         {% if menu|length > 1 %}
  14.             <ul class="nav nav-tabs" id="myTab" role="tablist">
  15.                 {% for projectName, projectMenu in menu %}
  16.                     <li class="nav-item">
  17.                         <a class="nav-link {% if projectName == activeProject %}active{% endif %}"
  18.                            id="{{ projectName }}-tab"
  19.                            data-toggle="tab"
  20.                            href="#{{ projectName }}"
  21.                            role="tab"
  22.                            aria-controls="{{ projectName }}"
  23.                            aria-selected="{% if projectName == activeProject %}true{% else %}false{% endif %}"
  24.                         >{{ projectName|trans }}</a>
  25.                     </li>
  26.                 {% endfor %}
  27.             </ul>
  28.         {% endif %}
  29.         <div class="tab-content" id="menuContent">
  30.             {% for projectName, projectMenu in menu %}
  31.                 <div class="tab-pane fade {% if projectName == activeProject %}active show{% endif%}"
  32.                      id="{{ projectName }}"
  33.                      role="tabpanel"
  34.                      aria-labelledby="{{ projectName }}-tab"
  35.                 >
  36.                     <ul class="list-unstyled text-left">
  37.                         {% for categoryName, reportsByCategory in projectMenu %}
  38.                             {% set showMenuCategory = reportsByCategory.granted is null %}
  39.                             {% for role in reportsByCategory.granted %}
  40.                                 {% if not showMenuCategory %}
  41.                                     {% set showMenuCategory = is_granted(role) %}
  42.                                 {% endif %}
  43.                             {% endfor %}
  44.                             {% if showMenuCategory %}
  45.                                 <li class="mt-2 text-center">
  46.                                     {{ categoryName|trans }}
  47.                                     <hr class="mt-0">
  48.                                 </li>
  49.                                 {% for reportPath, report in reportsByCategory.reports %}
  50.                                     {% set showMenuRow = report.granted is null %}
  51.                                     {% for role in report.granted %}
  52.                                         {% if not showMenuRow %}
  53.                                             {% set showMenuRow = is_granted(role) %}
  54.                                         {% endif %}
  55.                                     {% endfor %}
  56.                                     {% if showMenuRow %}
  57.                                         <li>
  58.                                             <a {{ currentRoute == reportPath ? 'class="active"' : '' }} href="{{ path(reportPath) }}">
  59.                                                 {{ report.name|trans }}
  60.                                             </a>
  61.                                         </li>
  62.                                     {% endif %}
  63.                                 {% endfor %}
  64.                             {% endif %}
  65.                         {% endfor %}
  66.                         <li class="mt-2 text-center">
  67.                             {{ 'system'|trans }}
  68.                             <hr class="mt-0">
  69.                         </li>
  70.                         <li>
  71.                             <a href="{{ path('app_logout') }}">{{ 'logout'|trans }}</a>
  72.                         </li>
  73.                     </ul>
  74.                 </div>
  75.             {% endfor %}
  76.             {% if not menu|length %}
  77.                 <ul class="list-unstyled text-left">
  78.                     <li>
  79.                         <a href="{{ path('app_logout') }}">{{ 'logout'|trans }}</a>
  80.                     </li>
  81.                 </ul>
  82.             {% endif %}
  83.         </div>
  84.     </div>
  85. </div>