I'm using SonataAdmin and I can't see the user block displayed in the template (on the top right) although I have replaced it with my custom template as mentioned in the configuration here https://sonata-project.org/bundles/admin/3-x/doc/reference/templates.html
I'm using SonataUserBundle and this is my configuration:
sonata_admin:
templates:
user_block: ApplicationSonataUserBundle:Default:user_block.html.twig
and these are the versions I'm using:
"require": {
"php": ">=5.5.9",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/orm": "^2.5",
"incenteev/composer-parameter-handler": "^2.0",
"sensio/distribution-bundle": "^5.0.19",
"sensio/framework-extra-bundle": "^5.0.0",
"sonata-project/admin-bundle": "^3.43",
"sonata-project/doctrine-orm-admin-bundle": "^3.7",
"sonata-project/user-bundle": "4.0.0",
"symfony/monolog-bundle": "^3.1.0",
"symfony/polyfill-apcu": "^1.0",
"symfony/swiftmailer-bundle": "^2.6.4",
"symfony/symfony": "3.4.*",
"twig/twig": "^1.0||^2.0"
},
I get no error however the user icon on the top right is not displayed !
What am I missing here ?
ok so I found that sonata is testing if the user has role_admin
to display the user_block
as mentioned here https://github.com/sonata-project/SonataAdminBundle/blob/3.x/src/Resources/views/standard_layout.html.twig#L194
look for this condition:
{% if app.user and is_granted(sonata_admin.adminPool.getOption('role_admin')) %}
and since all users has the role ROLE_USER
I just need to give this information to sonata, in the config.yml file, so it will display the user_block
to all connected users, like so:
sonata_admin:
security:
role_admin: ROLE_USER