Reputation: 1522
all works fine but i can't see logout icon and + icon in top right
i followed all step in sonata-project officiel site but i don't know what is happen really. in the officiel site i see in demo in the last step logout but in my project i can't
i use symfony 2.8.0
this my config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
- { resource: "@AppBundle/Resources/config/admin.yml" }
parameters:
locale: en
framework:
#esi: ~
translator: { fallbacks: ["%locale%"] }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
#serializer: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# handler_id set to null will use default session handler from php.ini
handler_id: ~
fragments: ~
http_method_override: true
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
# app/config/config.yml
sonata_block:
default_contexts: [cms]
blocks:
# enable the SonataAdminBundle block
sonata.admin.block.admin_list:
contexts: [admin]
Upvotes: 1
Views: 1517
Reputation: 948
There is a simple way to accomplish this without the need to add the SonataUserBundle. You can use a custom made template for user_block where you can add the logout link and links to some profile view by doing the following.
Add this to your security.yml
security:
role_hierarchy
ROLE_ADMIN: [ROLE_USER, ROLE_SONATA_ADMIN]
Now add this to your config.yml
## Sonata Configuration
# Sonata Admin
sonata_admin:
## ... other config
templates:
user_block: AppBundle:Default:user_block.html.twig
Finally add a template file called user_block.html.twig in src/AppBundle/Resources/views/Default/ with your desired links and content (below an example of the default user_block of the SonataUserBundle
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <[email protected]>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% block user_block %}
{% if app.user %}
{% set _bg_class = "bg-light-blue" %}
{% set _logout_uri = url('sonata_user_admin_security_logout') %}
{% set _logout_text = 'user_block_logout'|trans({}, 'SonataUserBundle') %}
{% set _profile_uri = sonata_user.userAdmin.isGranted('EDIT', app.user) ? sonata_user.userAdmin.generateUrl('edit', {id: app.user.id}) : sonata_user.userAdmin.generateUrl('show', {id: app.user.id}) %}
{% set _profile_text = 'user_block_profile'|trans({}, 'SonataUserBundle') %}
{% set _user_image = sonata_user.defaultAvatar ? asset(sonata_user.defaultAvatar) : null %}
{# Customize this with your profile picture implementation, see below for example #}
{#{% set _user_image = app.user.profilePicture|default(asset(sonata_user.defaultAvatar)) %}#}
{% if is_granted('ROLE_PREVIOUS_ADMIN') and sonata_user.impersonating %}
{% set _bg_class = "bg-light-green" %}
{% set _logout_uri = url(sonata_user.impersonating.route, sonata_user.impersonating.parameters| merge({'_switch_user': '_exit'})) %}
{% set _logout_text = 'switch_user_exit'|trans({}, 'SonataUserBundle') %}
{% endif %}
<li class="user-header {{ _bg_class }}">
{% if _user_image %}
<img src="{{ _user_image }}" class="img-circle" alt="Avatar"/>
{% endif %}
<p>{{ app.user }}</p>
</li>
<li class="user-body">
</li>
<li class="user-footer">
<div class="pull-left">
<a href="{{ _profile_uri }}" class="btn btn-default btn-flat"><i
class="fa fa-user"></i> {{ _profile_text }}</a>
</div>
<div class="pull-right">
<a href="{{ _logout_uri }}" class="btn btn-default btn-flat"><i
class="fa fa-sign-out fa-fw"></i> {{ _logout_text }}</a>
</div>
</li>
{% endif %}
{% endblock %}
But in my honest opinion it is best to implement the SonataUserBundle and I use it together with the FOSUserBundle and FOSOauthServerBundle.
Upvotes: 2
Reputation: 15070
I think that this behaviour is handled by SonataUserBundle, you must to install this, if you see in the Sonata User introduction you can see that this bundle enable the user profile, and I think that this user icon.
Upvotes: 0