<commit_before>{% 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('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.level > 1 ? '<i class="fa fa-angle-double-right"></i>' : '' %}
        {% set is_link = true %}
        {{ parent() }}
    {% endspaceless %}
{% endblock %}

{% block spanElement %}
    {% spaceless %}

        <a href="#">
            {% set translation_domain = item.attribute('label_catalogue') %}
            {% set icon = item.attribute('icon')|default ? item.attribute('icon') : '' %}
            {{ icon|default|raw }}
            {{ parent() }}
            <i class="fa pull-right fa-angle-left"></i>
        </a>
    {% 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 %}<commit_msg>Add menu extra option to enable activated state + Enable custom icons for menu links<commit_after>{% 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 ? '<i class="fa fa-angle-double-right"></i>' : '') %}
        {% set is_link = true %}
        {{ parent() }}
    {% endspaceless %}
{% endblock %}

{% block spanElement %}
    {% spaceless %}

        <a href="#">
            {% set translation_domain = item.attribute('label_catalogue') %}
            {% set icon = item.attribute('icon')|default ? item.attribute('icon') : '' %}
            {{ icon|default|raw }}
            {{ parent() }}
            <i class="fa pull-right fa-angle-left"></i>
        </a>
    {% 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 %}
{'fraction_non_alphanumeric': 0.19438968915845337, 'fraction_numerical': 0.00030326004548900684, 'mean_word_length': 2.508510638297872, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7308731', 'n_tokens_mistral': 2156, 'n_tokens_neox': 1911, 'n_words': 419}