Search code examples
symfonysonata-adminsymfony-2.3

sonataAdminBundle top navigation username and logout buttons


Symfony2 in current 2.3 version. I've installed sonataAdminBundle in dev-master version. I have fosUserBundle in dev-master too. The problem is that I have no username and logout buttons in the top of admin panel (navigation).

I noticed that user_block.html.twig says:

{% block user_block %}{# Customize this value #}{% endblock %}

But how can I customize that? There is no navigation for logout by default bundle settings?


Solution

  • I think you should install SonataUserBundle that overrides the user_block.html.twig template with what you are looking for:

    {% block user_block %}
        {% if app.user %}
            {{ app.user }}
    
            {% if is_granted('ROLE_PREVIOUS_ADMIN') and sonata_user.impersonating %}
                <a href="{{ url(sonata_user.impersonating.route, sonata_user.impersonating.parameters| merge({'_switch_user': '_exit'})) }}">(exit)</a>
            {% endif %}
    
            - <a href="{{ url('sonata_user_admin_security_logout') }}">{{ 'user_block_logout'|trans({}, 'SonataUserBundle') }}</a>
        {% endif %}
    {% endblock %}
    

    Here is the template: https://github.com/sonata-project/SonataUserBundle/blob/master/Resources/views/Admin/Core/user_block.html.twig.