Unrecognized options "sonata.user.block.menu, - symfony

I am trying to Create ACL following this documentation. after following till last step accurately when i reloaded my page by hitting this localhost/project/web/app_dev.php/profile/
url i got following error
InvalidConfigurationException: Unrecognized options "sonata.user.block.menu, sonata.user.block.account, sonata.block.service.text" under "sonata_block.blocks.sonata.admin.block.admin_list"
I then went to my file and commented these lines (just to check what can be the result, al thought it doesn't make any sense ) then i got following error
InvalidTypeException: Invalid type for path "sonata_user.profile.dashboard.blocks.position". Expected array, but got string
I don't know whats the issue, just first time working with sonata and new to symfony.
Here is my config.yml file
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: #swaamPatientBundle/Resources/config/admin.yml }
framework:
#esi: ~
#translator: { fallback: "%locale%" }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { 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%"
# Assetic Configuration
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [ ]
#java: /usr/bin/java
filters:
cssrewrite: ~
#closure:
# jar: "%kernel.root_dir%/Resources/java/compiler.jar"
#yui_css:
# jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
# Doctrine Configuration
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver, add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# path: "%database_path%"
types:
json: Sonata\Doctrine\Types\JsonType
orm:
auto_generate_proxy_classes: "%kernel.debug%"
# auto_mapping: true
entity_managers:
default:
mappings:
ApplicationSonataUserBundle: ~
SonataUserBundle: ~
FOSUserBundle: ~
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
sonata_user:
google_authenticator:
enabled: true
server: yourserver.com
security_acl: true
manager_type: orm # can be orm or mongodb
table:
user_group: "my_custom_user_group_association_table_name"
impersonating:
route: page_slug
parameters: { path: / }
class: # Entity Classes
user: Application\Sonata\UserBundle\Entity\User
group: Application\Sonata\UserBundle\Entity\Group
admin: # Admin Classes
user:
class: Sonata\UserBundle\Admin\Entity\UserAdmin
controller: SonataAdminBundle:CRUD
translation: SonataUserBundle
group:
class: Sonata\UserBundle\Admin\Entity\GroupAdmin
controller: SonataAdminBundle:CRUD
translation: SonataUserBundle
profile:
default_avatar: 'bundles/sonatauser/default_avatar.png' # Default avatar displayed if user doesn't have one
# As in SonataAdminBundle's dashboard
dashboard:
groups:
# Prototype
id:
label: ~
label_catalogue: ~
items: []
item_adds: []
roles: []
blocks:
type: ~
settings:
# Prototype
id: []
position: right
register:
# You may customize the registration forms over here
form:
type: sonata_user_registration
handler: sonata.user.registration.form.handler.default
name: sonata_user_registration_form
validation_groups:
# Defaults:
- Registration
- Default
# This allows you to specify where you want your user redirected once he activated his account
confirm:
redirect:
# Set it to false to disable redirection
route: 'sonata_user_profile_show'
route_parameters: ~
# Customize user portal menu by setting links
menu:
- { route: 'sonata_user_profile_edit', label: 'link_edit_profile', domain: 'SonataUserBundle'}
- { route: 'sonata_user_profile_edit_authentication', label: 'link_edit_authentication', domain: 'SonataUserBundle'}
# Profile Form (firstname, lastname, etc ...)
form:
type: sonata_user_profile
handler: sonata.user.profile.form.handler.default
name: sonata_user_profile_form
validation_groups: [Profile]
# override FOSUser default serialization
jms_serializer:
metadata:
directories:
- { path: %kernel.root_dir%/../vendor/sonata-project/user-bundle/Sonata/UserBundle/Resources/config/serializer/FOSUserBundle, namespace_prefix: 'FOS\UserBundle' }
# Enable Doctrine to map the provided entities
sonata_block:
default_contexts: [cms]
blocks:
# Enable the SonataAdminBundle block
sonata.admin.block.admin_list:
contexts: [admin]
sonata.user.block.menu: # used to display the menu in profile pages
sonata.user.block.account: # used to display menu option (login option)
sonata.block.service.text: # used to if you plan to use Sonata user routes
# Your other blocks
sonata_admin:
title: Patient Bundle
# title_logo: bundles/acmedemo/img/fancy_acme_logo.png
security:
access_control:
# URL of FOSUserBundle which need to be available to anonymous users
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
# Admin login page needs to be access without credential
- { path: ^/admin/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/logout$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/login_check$, role: IS_AUTHENTICATED_ANONYMOUSLY }
# Secured part of the site
# This config requires being logged for the whole site and having the admin role for the admin part.
# Change these rules to adapt them to your needs
- { path: ^/admin/, role: [ROLE_ADMIN, ROLE_SONATA_ADMIN] }
- { path: ^/.*, role: IS_AUTHENTICATED_ANONYMOUSLY }
# [...]
acl:
connection: default
fos_user:
db_driver: orm # can be orm or odm
firewall_name: main
user_class: Sonata\UserBundle\Entity\BaseUser
group:
# group_class: Sonata\UserBundle\Entity\BaseGroup
# group_manager: sonata.user.orm.group_manager # If you're using doctrine orm (use sonata.user.mongodb.user_manager for mongodb)
group_class: Application\Sonata\UserBundle\Entity\Group
group_manager: sonata.user.orm.group_manager # If you're using doctrine orm (use sonata.user.mongodb.user_manager for mongodb)
profile:
# Authentication Form
form:
type: fos_user_profile
handler: fos_user.profile.form.handler.default
name: fos_user_profile_form
validation_groups: [Authentication] # Please note : this is not the default value
service:
user_manager: sonata.user.orm.user_manager # If you're using doctrine orm (use sonata.user.mongodb.group_manager for mongodb)
Question edited !!!
Ok, while Waiting for the answer i commented those menu section lines and then profile.register.menu
and i got log in form against localhost/patient/web/app_dev.php/admin/login url...
But still don't knw any other way to fix it ? ? ?
does commenting them will cause problem ?

you should fix your indentation, check this :
sonata_block:
default_contexts: [cms]
blocks:
# Enable the SonataAdminBundle block
sonata.admin.block.admin_list:
contexts: [admin]
sonata.user.block.menu: # used to display the menu in profile pages
sonata.user.block.account: # used to display menu option (login option)
sonata.block.service.text: # used to if you plan to use Sonata user routes
your error is here :
sonata_block:
default_contexts: [cms]
blocks:
# Enable the SonataAdminBundle block
sonata.admin.block.admin_list:
contexts: [admin]
sonata.user.block.menu: # used to display the menu in profile pages
sonata.user.block.account: # used to display menu option (login option)
sonata.block.service.text: # used to if you plan to use Sonata user routes

Related

Fosuserbundle : Redirection to check email page after registration does'nt work on server

I encounter a problem and I have no idea how to solve it.
I realized a symfony project in which there are user accounts (I used fosuserbundle). When a user registers, he is redirected to the "check-email" page.
It works fine from my local computer.
But on the server where the project is deposited, it brings me back on the registration form, the mail is sent but no check email page is displayed.
I have cleared the cache, all the files are up to date, so where can it come from?
If you have an idea, it would be great, thank you
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
# Put parameters here that don't need to change on each machine where the app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: fr
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']
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# http://symfony.com/doc/current/reference/configuration/framework.html#handler-id
handler_id: session.handler.native_file
save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%"
fragments: ~
http_method_override: true
assets: ~
php_errors:
log: true
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
form_themes:
- 'bootstrap_3_horizontal_layout.html.twig'
- 'VichUploaderBundle:Form:fields.html.twig'
globals:
nb_news_per_page: '%nb_news_per_page%'
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/../var/data/data.sqlite"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
#path: "%database_path%"
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 }
knp_paginator:
page_range: 6
default_options:
page_name: page
sort_field_name: sort
sort_direction_name: direction
distinct: true
template:
pagination: KnpPaginatorBundle:Pagination:twitter_bootstrap_v3_pagination.html.twig
sortable: KnpPaginatorBundle:Pagination:sortable_link.html.twig
fos_user:
db_driver: orm
firewall_name: main
user_class: ACT\UserBundle\Entity\User
registration:
confirmation:
enabled: true
template: ACTUserBundle:Registration:email.txt.twig
from_email:
address: #mon adresse
sender_name: admin
service:
user_manager: pugx_user_manager
mailer: fos_user.mailer.twig_swift
resetting:
email:
template: '#FOSUser/Resetting/email.txt.twig'
pugx_multi_user:
users:
user_candidat:
entity:
class: ACT\UserBundle\Entity\Candidat
registration:
form:
type: ACT\UserBundle\Form\RegistrationCandidatFormType
name: act_userbundle_candidat
template: ACTUserBundle:Registration:user_candidat.form.html.twig
profile:
form:
type: ACT\UserBundle\Form\ProfilCandidatFormType
template: ACTUserBundle:Profile:user_candidat_p.form.html.twig
user_referent:
entity:
class: ACT\UserBundle\Entity\Referent
registration:
form:
type: ACT\UserBundle\Form\RegistrationReferentFormType
name: act_userbundle_referent
template: ACTUserBundle:Registration:user_referent.form.html.twig
profile:
form:
type: ACT\UserBundle\Form\ProfilReferentFormType
template: ACTUserBundle:Profile:user_referent_p.form.html.twig
assetic:
debug: '%kernel.debug%'
use_controller: '%kernel.debug%'
filters:
cssrewrite: ~
jsqueeze: ~
scssphp:
formatter: 'Leafo\ScssPhp\Formatter\Compressed'

Sonata User Advanced Configuration

I am trying to configure the advanced configuration of the SonataUser Bundle(https://sonata-project.org/bundles/user/3-x/doc/reference/advanced_configuration.html).
After following the documentation I get the following errors on installing assets:
[Symfony\Component\Config\Exception\FileLoaderLoadException]
There is no extension able to load the configuration for "jms_serializer" (in /var/www/html/SonataProject/app/config/config.yml). Looked for
namespace "jms_serializer", found "framework", "security", "twig", "monolog", "swiftmailer", "doctrine", "sensio_framework_extra", "fos_use
r", "sonata_core", "sonata_block", "knp_menu", "sonata_doctrine_orm_admin", "sonata_admin", "sonata_easy_extends", "sonata_user", "debug", "
web_profiler", "sensio_distribution" in /var/www/html/SonataProject/app/config/config.yml (which is being imported from "/var/www/html/Sonat
aProject/app/config/config_dev.yml").
After I comment out jms_serializer configuration, I get another error:
[Symfony\Component\Config\Definition\Exception\InvalidTypeException]
Invalid type for path "sonata_user.profile.dashboard.blocks.position". Expected array, but got string
Here is my config.yml:
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
# Put parameters here that don't need to change on each machine where the app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
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:
types:
json: Sonata\Doctrine\Types\JsonType
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
# naming_strategy: doctrine.orm.naming_strategy.underscore
# auto_mapping: true
entity_managers:
default:
mappings:
ApplicationSonataUserBundle: ~
SonataUserBundle: ~
FOSUserBundle: ~
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
#FOSUser Configuration
fos_user:
db_driver: orm
firewall_name: main
user_class: Application\Sonata\UserBundle\Entity\User
group:
group_class: Application\Sonata\UserBundle\Entity\Group
group_manager: sonata.user.orm.group_manager
profile:
# Authentication Form
form:
type: fos_user_profile
handler: fos_user.profile.form.handler.default
name: fos_user_profile_form
validation_groups: [Authentication]
service:
user_manager: sonata.user.orm.user_manager
#SonataUser
sonata_user:
security_acl: false
manager_type: orm
table:
user_group: "my_custom_user_group_association_table_name"
impersonating:
route: page_slug
parameters: { path: / }
class:
user: Sonata\UserBundle\Entity\User
group: Sonata\UserBundle\Entity\Group
admin: # Admin Classes
user:
class: Sonata\UserBundle\Admin\Entity\UserAdmin
controller: SonataAdminBundle:CRUD
translation: SonataUserBundle
group:
class: Sonata\UserBundle\Admin\Entity\GroupAdmin
controller: SonataAdminBundle:CRUD
translation: SonataUserBundle
profile:
# As in SonataAdminBundle's dashboard
dashboard:
groups:
# Prototype
id:
label: ~
label_catalogue: ~
items: []
item_adds: []
roles: []
blocks:
type: ~
settings:
# Prototype
id: []
position: right
register:
# You may customize the registration forms over here
form:
type: sonata_user_registration
handler: sonata.user.registration.form.handler.default
name: sonata_user_registration_form
validation_groups:
# Defaults:
- Registration
- Default
# This allows you to specify where you want your user redirected once he activated his account
confirm:
redirect:
# Set it to false to disable redirection
route: 'sonata_user_profile_show'
route_parameters: ~
# Customize user portal menu by setting links
menu:
- { route: 'sonata_user_profile_edit', label: 'link_edit_profile', domain: 'SonataUserBundle'}
- { route: 'sonata_user_profile_edit_authentication', label: 'link_edit_authentication', domain: 'SonataUserBundle'}
# Profile Form (firstname, lastname, etc ...)
form:
type: sonata_user_profile
handler: sonata.user.profile.form.handler.default
name: sonata_user_profile_form
validation_groups: [Profile]
# override FOSUser default serialization
jms_serializer:
metadata:
directories:
- { path: %kernel.root_dir%/../vendor/sonata-project/user-bundle/Sonata/UserBundle/Resources/config/serializer/FOSUserBundle, namespace_prefix: 'FOS\UserBundle' }
#SonataAdmin
sonata_block:
default_contexts: [cms]
blocks:
# enable the SonataAdminBundle block
sonata.admin.block.admin_list:
contexts: [admin]
sonata.user.block.menu: # used to display the menu in profile pages
sonata.user.block.account: # used to display menu option (login option)
sonata.block.service.text:
sonata.block.service.rss:
Any ideas??
EDIT:
For the second error I tried editing the sonata_user.profile.dashboard.blocks as follows:
blocks:
type: ~
settings:
position: right
# Prototype
id: []
I am not sure if this is correct configuration but the error goes away.
Awaiting response!
Look at the doc the position is indented differently :
blocks:
type: ~
settings:
# Prototype
id: []
position: right
In yours, position is just under the id... Might be that

Sonata - missing user security status labels

I don't know why but since today Status labels just gone...
I can change Status but there is no labels so I don't what I'm doing ;-)
app\config\config.yml
imports:
- { resource: #MyProductBundle/Resources/config/parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
- { resource: #MyProductBundle/Resources/config/admin.yml }
- { resource: ../../vendor/knplabs/doctrine-behaviors/config/orm-services.yml }
#-------------------------------------------------------------------------------------------------------------------------------------------------------------
framework:
#esi: ~
translator: { fallbacks: ["%locale%"] }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { 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%"
form:
resources: ['bootstrap_3_layout.html.twig']
# resources: ['bootstrap_3_horizontal_layout.html.twig]
#-------------------------------------------------------------------------------------------------------------------------------------------------------------
# Assetic Configuration
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [ ]
#java: /usr/bin/java
filters:
cssrewrite: ~
#closure:
# jar: "%kernel.root_dir%/Resources/java/compiler.jar"
#yui_css:
# jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
#-------------------------------------------------------------------------------------------------------------------------------------------------------------
# Doctrine Configuration
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
types:
json: Sonata\Doctrine\Types\JsonType
orm:
auto_generate_proxy_classes: "%kernel.debug%"
entity_managers:
default:
auto_mapping: true
mappings:
gedmo_translatable:
type: annotation
prefix: Gedmo\Translatable\Entity
dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity"
alias: GedmoTranslatable # this one is optional and will default to the name set for the mapping
is_bundle: false
gedmo_translator:
type: annotation
prefix: Gedmo\Translator\Entity
dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translator/Entity"
alias: GedmoTranslator # this one is optional and will default to the name set for the mapping
is_bundle: false
#-------------------------------------------------------------------------------------------------------------------------------------------------------------
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
#-------------------------------------------------------------------------------------------------------------------------------------------------------------
# FOSUserBundle Configuration
fos_user:
db_driver: orm
firewall_name: main
user_class: Application\Sonata\UserBundle\Entity\User
group:
group_class: Application\Sonata\UserBundle\Entity\Group
group_manager: sonata.user.orm.group_manager
service:
user_manager: sonata.user.orm.user_manager
#-------------------------------------------------------------------------------------------------------------------------------------------------------------
# Sonata Configuration
sonata_user:
security_acl: true
table:
user_group: fos_user_user_group
manager_type: orm
profile:
form:
type: sonata_user_profile
handler: sonata.user.profile.form.handler.default
name: sonata_user_profile_form
validation_groups:
# Defaults:
- Profile
- Default
dashboard:
blocks:
- { position: left, type: sonata.block.service.text, settings: { content: "<h2>Welcome!</h2> This is a sample user profile dashboard, feel free to override it in the configuration! Want to make this text dynamic? For instance display the user's name? Create a dedicated block and edit the configuration!"} }
# - { position: right, type: sonata.news.block.recent_comments, settings: { title: Recent Comments, number: 5, mode: public }}
# Customize user portal menu by setting links
menu:
- { route: 'sonata_user_profile_show', label: 'sonata_profile_title', domain: 'SonataUserBundle'}
- { route: 'sonata_user_profile_edit', label: 'link_edit_profile', domain: 'SonataUserBundle'}
- { route: 'sonata_user_profile_edit_authentication', label: 'link_edit_authentication', domain: 'SonataUserBundle'}
sonata_admin:
security:
handler: sonata.admin.security.handler.noop
title: JustShop (-;
title_logo: img/logo.png
dashboard:
blocks:
# display a dashboard block
-
position: left
type: sonata.admin.block.admin_list
# Customize this part to add new block configuration
-
position: right,
type: sonata.block.service.text,
settings:
content: "<h2>Welcome to the Sonata Admin</h2> <p>This is a <code>sonata.block.service.text</code> from the Block Bundle, you can create and add new block in these area by configuring the <code>sonata_admin</code> section.</p> <br /> For instance, here a RSS feed parser (<code>sonata.block.service.rss</code>):"
-
position: right
type: sonata.block.service.rss
settings:
title: Sonata Projects Feeds
url: http://sonata-project.org/blog/archive.rss
persist_filters: true
sonata_block:
default_contexts: [cms]
blocks:
# Enable the SonataAdminBundle block
sonata.admin.block.admin_list:
contexts: [admin]
sonata.admin.block.search_result:
contexts: [admin]
sonata.user.block.menu: # used to display the menu in profile pages
sonata.user.block.account: # used to display menu option (login option)
sonata.block.service.text: # used to if you plan to use Sonata user routes
sonata.block.service.rss:
#-------------------------------------------------------------------------------------------------------------------------------------------------------------
stof_doctrine_extensions:
default_locale: en_US
translation_fallback: true
orm:
default:
sluggable: true
timestampable: true
translatable: true
#-------------------------------------------------------------------------------------------------------------------------------------------------------------
a2lix_translation_form:
locale_provider: default
locales: [en, pl]
default_locale: en
required_locales: [en]
manager_registry: doctrine
templating: "A2lixTranslationFormBundle::default.html.twig"
app\config\security.yml
# you can read more about security in the related section of the documentation
# http://symfony.com/doc/current/book/security.html
security:
# http://symfony.com/doc/current/book/security.html#encoding-the-user-s-password
encoders:
FOS\UserBundle\Model\UserInterface: sha512
# http://symfony.com/doc/current/book/security.html#hierarchical-roles
role_hierarchy:
ROLE_ADMIN: [ROLE_USER, ROLE_SONATA_ADMIN]
ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
SONATA:
- ROLE_SONATA_PAGE_ADMIN_PAGE_EDIT # if you are using acl then this line must be commented
providers:
# http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers
providers:
fos_userbundle:
id: fos_user.user_manager
# the main part of the security, where you can set up firewalls
# for specific sections of your app
firewalls:
# disables authentication for assets and the profiler, adapt it according to your needs
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
# -> custom firewall for the admin area of the URL
admin:
switch_user: true
context: user
pattern: /admin(.*)
form_login:
provider: fos_userbundle
login_path: /login
use_forward: false
check_path: /admin/login_check
failure_path: null
use_referer: true
logout:
path: /logout
target: /login
anonymous: true
remember_me:
key: 9034895c8e6816cad3f8fc4d3171bce10
lifetime: 3600
path: /
domain: ~
# -> end custom configuration
# defaut login area for standard users
main:
switch_user: true
context: user
pattern: .*
form_login:
provider: fos_userbundle
login_path: /login
use_forward: false
check_path: /login_check
failure_path: null
logout: true
anonymous: true
remember_me:
key: 9034895c8e6816cad3f8fc4d3171bce10
lifetime: 3600
path: /
domain: ~
acl:
connection: default
# with these settings you can restrict or allow access for different parts
# of your application based on roles, ip, host or methods
# http://symfony.com/doc/current/cookbook/security/access_control.html
access_control:
# URL of FOSUserBundle which need to be available to anonymous users
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
# Admin login page needs to be access without credential
- { path: ^/admin/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/logout$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/login_check$, role: IS_AUTHENTICATED_ANONYMOUSLY }
# Secured part of the site
# This config requires being logged for the whole site and having the admin role for the admin part.
# Change these rules to adapt them to your needs
- { path: ^/admin/, role: [ROLE_ADMIN, ROLE_SONATA_ADMIN] }
- { path: ^/product/, role: IS_AUTHENTICATED_FULLY }
- { path: ^/.*, role: IS_AUTHENTICATED_ANONYMOUSLY }
It's a bug in symfony(?) bootstrap defaults configuration
changed from
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
form:
resources: ['bootstrap_3_layout.html.twig']
# resources: ['bootstrap_3_horizontal_layout.html.twig]
to
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
form:
# resources: ['bootstrap_3_layout.html.twig']
# resources: ['bootstrap_3_horizontal_layout.html.twig]

How to add bundles in the Admin Dashboard Symfony2

I'm working on Sonata Admin bundles. I've configure the Admin Dashboard and the following components are showing in the "Symfony CMF" group,
Here's the snapshot,
I've gone through the Symfony CMF sandbox site,
http://cmf.liip.ch/en/admin/dashboard
In this dashboard there are some other bundles like ,
Simple Block
Container Block etc are appearing.
Here's the snapshot,
I want to add the Content items as shown in the above pic in my "Symfony CMF" group.
How to do it ?
Here's my config.yml,
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: #IFISBMainBundle/Resources/config/admin.yml }
- { resource: doctrine_extensions.yml }
framework:
#esi: ~
translator: { fallback: en }
secret: %secret%
router: { resource: "%kernel.root_dir%/config/routing.yml" }
form: true
templating: { engines: ['twig'] } #assets_version: SomeVersionScheme
default_locale: %locale%
session: ~
# Twig Configuration
twig:
debug: %kernel.debug%
strict_variables: %kernel.debug%
# Assetic Configuration
assetic:
debug: %kernel.debug%
use_controller: false
#bundles: [CmfSimpleCmsBundle, CmfCreateBundle]
#java: /usr/bin/java
filters:
cssrewrite: ~
#lessphp:
#file: %kernel.root_dir%/../vendor/leafo/lessphp/lessc.inc.php
#apply_to: "\.less$"
#closure:
# jar: %kernel.root_dir%/Resources/java/compiler.jar
#yui_css:
# jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar
# for jackalope-doctrine-dbal
doctrine:
dbal:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
path: %database_path%
charset: UTF8
types:
json: Sonata\Doctrine\Types\JsonType
orm:
entity_managers:
default:
auto_mapping: true
mappings:
ApplicationSonataUserBundle: ~
SonataUserBundle: ~
loggable:
type: annotation
alias: Gedmo
prefix: Gedmo\Loggable\Entity
dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Loggable/Entity"
# cmf configuration
doctrine_phpcr:
# configure the PHPCR session
session:
backend:
type: %phpcr_backend%
workspace: %phpcr_workspace%
username: %phpcr_user%
password: %phpcr_pass%
# enable the ODM layer
odm:
auto_mapping: true
auto_generate_proxy_classes: %kernel.debug%
locales:
en:
- de
de:
- en
liip_doctrine_cache:
namespaces:
meta:
type: file_system
nodes:
type: file_system
cmf_core:
persistence:
phpcr:
enabled: true
basepath: /cms
publish_workflow:
enabled: false
multilang:
locales: %locales%
cmf_create:
editor_base_path: /bundles/cmfcreate/vendor/ckeditor/
cmf_simple_cms:
routing:
templates_by_class:
Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page: CmfSimpleCmsBundle:Page:index.html.twig
controllers_by_class:
Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\RedirectRoute: cmf_routing.redirect_controller:redirectAction
cmf_routing:
chain:
routers_by_id:
cmf_routing.dynamic_router: 20
router.default: 100
dynamic:
enabled: true
persistence:
phpcr:
route_basepath: /cms/routes
knp_menu:
twig: true
lunetics_locale:
strict_mode: true
guessing_order:
- cookie
- router
- browser
allowed_locales: %locales%
sonata_block:
default_contexts: [cms]
blocks:
sonata.user.block.menu: # used to display the menu in profile pages
sonata.user.block.account: # used to display menu option (login option)
sonata.block.service.text:
sonata.block.service.rss:
sonata.admin.block.admin_list:
contexts: [admin]
sonata_admin_doctrine_phpcr.tree_block:
settings:
id: '/cms'
contexts: [admin]
sonata_admin:
title: Admin
title_logo: bundles/acmemain/images/if_logo_small.gif
templates:
# default global templates
ajax: SonataAdminBundle::ajax_layout.html.twig
dashboard:
blocks:
# display a dashboard block
- { position: right, type: sonata.admin.block.admin_list }
- { position: left, type: sonata_admin_doctrine_phpcr.tree_block }
sonata_doctrine_phpcr_admin:
document_tree:
Doctrine\ODM\PHPCR\Document\Generic:
valid_children:
- all
Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page:
valid_children:
- all
Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route:
valid_children:
- Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route
- Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\RedirectRoute
Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\RedirectRoute:
valid_children: []
Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\MenuNode:
valid_children:
- Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\MenuNode
swiftmailer:
transport: gmail
username: witribeman#gmail.com
password: headphones
logging: "%kernel.debug%"
fos_user:
db_driver: orm # can be orm or odm
firewall_name: main
user_class: Application\Sonata\UserBundle\Entity\User
group:
group_class: Application\Sonata\UserBundle\Entity\Group
from_email:
address: noreply#ifi-admin.com
sender_name: IFI Admin
sonata_user:
security_acl: true
manager_type: orm # can be orm or mongodb
class:
user: Application\Sonata\UserBundle\Entity\User
I'm also confused from where and how Symfony CMF group items gets rendered.
Kindly, let me know how to add other CMF bundle under my Symfony CMF group.
Thanks,
Faisal Nasir
Put your entity service in dashboard
dashboard:
blocks:
# display a dashboard block
- { position: left, type: sonata.admin.block.admin_list, settings: { groups: [Personnel,Settings] } }
- { position: right, type: sonata.admin.block.admin_list }
groups:
Personnel: #Menu name
items:
- example.abc.a #your services
Settings: #Menu name
items:
- example.abc.a #your services

sonata user management check box is missing from role

my check box is missing from addnew user /management tab, when i was trying to create a new user in sonata user (means i can't access any role for assigning it to any user or for creating a role group
here is my
config.yml:
imports:
- { resource: parameters.yml }
- { resource: security.yml }
framework:
#esi: ~
translator: { fallback: %locale% }
secret: %secret%
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_proxies: ~
session: ~
fragments: ~
http_method_override: true
# Twig Configuration
twig:
debug: %kernel.debug%
strict_variables: %kernel.debug%
# Assetic Configuration
# Doctrine Configuration
doctrine:
dbal:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: UTF8
# if using pdo_sqlite as your database driver, add the path in parameters.yml
# e.g. database_path: %kernel.root_dir%/data/data.db3
# path: %database_path%
types:
json: Sonata\Doctrine\Types\JsonType
orm:
auto_generate_proxy_classes: %kernel.debug%
entity_managers:
default:
mappings:
ApplicationSonataUserBundle: ~
SonataUserBundle: ~
FOSUserBundle: ~
# Swiftmailer Configuration
swiftmailer:
transport: %mailer_transport%
host: %mailer_host%
username: %mailer_user%
password: %mailer_password%
spool: { type: memory }
bc_bootstrap:
less_filter: less
assets_dir: %kernel.root_dir%/../vendor/twitter/bootstrap
jquery_path: %kernel.root_dir%/../vendor/jquery/jquery/jquery-1.9.1.js
sonata_block:
default_contexts: [cms]
blocks:
# Enable the SonataAdminBundle block
sonata.admin.block.admin_list:
contexts: [admin]
sonata.block.service.text:
sonata.block.service.rss:
sonata.user.block.menu: # used to display the menu in profile pages
sonata.user.block.account: # used to display menu option (login option)
sonata_admin:
title: Admin
#title_logo: bundles/acmedemo/img/fancy_acme_logo.png
security:
handler: sonata.admin.security.handler.role
#acl_user_manager: fos_user.user_manager
# Name of the user manager service used to retrieve ACL users
options:
html5_validate: false
# does not use html5 validation
confirm_exit: false
# disable confirmation when quitting with unsaved changes
# set to true to persist filter settings per admin module in the user's session
#persist_filters: false
templates:
dashboard: SonataAdminBundle:Core:dashboard.html.twig
search: SonataAdminBundle:Core:search.html.twig
search_result_block: SonataAdminBundle:Block:block_search_result.html.twig
dashboard:
blocks:
-
position: left
type: sonata.admin.block.admin_list
-
position: right
type: sonata.block.service.text
settings:
content: >
<h2>Welcome Admin</h2>
sonata_user:
security_acl: false
manager_type: orm
# can be orm or mongodb
table:
user_group: "my_custom_user_group_association_table_name"
#impersonating:
# route: page_slug
# parameters: { path: / }
class: # Entity Classes
user: Application\Sonata\UserBundle\Entity\User
group: Application\Sonata\UserBundle\Entity\Group
admin: # Admin Classes
user:
class: Sonata\UserBundle\Admin\Entity\UserAdmin
controller: SonataAdminBundle:CRUD
translation: SonataUserBundle
group:
class: Sonata\UserBundle\Admin\Entity\GroupAdmin
controller: SonataAdminBundle:CRUD
translation: SonataUserBundle
profile:
menu:
- { route: 'sonata_user_profile_show', label: 'sonata_profile_title', domain: 'SonataUserBundle'}
- { route: 'sonata_user_profile_edit', label: 'link_edit_profile', domain: 'SonataUserBundle'}
#- { route: 'sonata_customer_addresses', label: 'link_list_addresses', domain: 'SonataCustomerBundle'}
- { route: 'sonata_user_profile_edit_authentication', label: 'link_edit_authentication', domain: 'SonataUserBundle'}
#- { route: 'sonata_order_index', label: 'order_list', domain: 'SonataOrderBundle'}
# This allows you to specify where you want your user redirected once he activated his account
form:
type: sonata_user_profile
handler: sonata.user.profile.form.handler.default
name: sonata_user_profile_form
validation_groups: [Profile]
google_authenticator:
enabled: true
server: yourserver.com
fos_user:
db_driver: orm
# other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: Application\Sonata\UserBundle\Entity\User
group:
group_class: Application\Sonata\UserBundle\Entity\Group
profile:
# Authentication Form
form:
type: fos_user_profile
handler: fos_user.profile.form.handler.default
name: fos_user_profile_form
validation_groups: [Authentication]
# Please note : this is not the default value
And here is my security.yml:
security:
encoders:
Symfony\Component\Security\Core\User\User: plaintext
FOS\UserBundle\Model\UserInterface: sha512
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
ROLE_USER: ROLE_MY_CUSTOM
providers:
in_memory:
memory:
users:
user: { password: userpass, roles: [ 'ROLE_USER' ] }
admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] }
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
pattern: ^/
context: user
form_login:
provider: fos_userbundle
login_path: /login
use_forward: false
check_path: /login_check
failure_path: null
logout: true
anonymous: true
admin:
pattern: /admin(.*)
context: user
form_login:
provider: fos_userbundle
login_path: /admin/login
use_forward: false
check_path: /admin/login_check
failure_path: null
logout:
path: /admin/logout
anonymous: true
acl:
connection: default
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN }
- { path: ^/demo/secured/hello/admin/, roles: ROLE_ADMIN }
#- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
access_decision_manager:
# Strategy can be: affirmative, unanimous or consensus
strategy: unanimous
And here is my routing.yml:
admin:
resource: '#SonataAdminBundle/Resources/config/routing/sonata_admin.xml'
prefix: /admin
_sonata_admin:
resource: .
type: sonata_admin
prefix: /admin
sonata_user:
resource: '#SonataUserBundle/Resources/config/routing/admin_security.xml'
prefix: /
fos_user_security:
resource: "#FOSUserBundle/Resources/config/routing/security.xml"
fos_user_profile:
resource: "#SonataUserBundle/Resources/config/routing/profile.xml"
prefix: /profile
fos_user_register:
resource: "#FOSUserBundle/Resources/config/routing/registration.xml"
prefix: /register
fos_user_resetting:
resource: "#FOSUserBundle/Resources/config/routing/resetting.xml"
prefix: /resetting
fos_user_change_password:
resource: "#FOSUserBundle/Resources/config/routing/change_password.xml"
prefix: /profile
Thank you in advance
Your connected user must have the ROLE_SUPER_ADMIN role
do a
php app/console fos:user:promote [username] ROLE_SUPER_ADMIN
and make sure to call this in your UserAdmin
->add('realRoles', 'sonata_security_roles', array(
'expanded' => true,
'multiple' => true,
'required' => false
))
For symfony 4, use this:
use Sonata\UserBundle\Form\Type\SecurityRolesType;
protected function configureFormFields(FormMapper $formMapper): void
{
$formMapper
->add('roles', SecurityRolesType::class, [
'expanded' => true,
'multiple' => true,
'required' => false,
]);
}

Resources