无法识别的选项“sonata.user.block.menu,

时间:2014-07-01 10:01:15

标签: symfony sonata-admin symfony-sonata sonata-user-bundle symfony-2.5

我正在尝试在this文档之后创建ACL。通过点击 localhost / project / web / app_dev.php / profile / 重新加载我的页面后,准确地关注到最后一步 url我收到了以下错误

InvalidConfigurationException:无法识别的选项" sonata.user.block.menu,sonata.user.block.account,sonata.block.service.text"在" sonata_block.blocks.sonata.admin.block.admin_list"

然后我转到我的文件并评论了这些行(只是为了检查结果是什么,以为它没有任何意义)然后我得到了以下错误

InvalidTypeException:path" sonata_user.profile.dashboard.blocks.position"的类型无效。预期的数组,但得到了字符串

我不知道这个问题是什么,只是第一次使用奏鸣曲和新的symfony。

这是我的config.yml文件

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)

问题编辑!!!

好的,在等待答案时,我评论了那些菜单部分行,然后是profile.register.menu

我登录了localhost / patient / web / app_dev.php / admin / login url ...

但仍然没有其他任何方法来修复它? ? ?

评论它们会导致问题吗?

1 个答案:

答案 0 :(得分:1)

你应该修复你的缩进,检查一下:

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

你的错误在这里:

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