Sonata用户高级配置

时间:2016-09-20 08:52:26

标签: symfony fosuserbundle sonata-user-bundle

我正在尝试配置SonataUser Bundle的高级配置(https://sonata-project.org/bundles/user/3-x/doc/reference/advanced_configuration.html)。

在遵循文档后,我在安装资产时遇到以下错误:

  1. [Symfony的\元器件\配置\异常\ FileLoaderLoadException]
    没有扩展程序可以加载“jms_serializer”的配置(在/var/www/html/SonataProject/app/config/config.yml中)。寻找
    命名空间“jms_serializer”,找到“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“在/var/www/html/SonataProject/app/config/config.yml(从”/ var / www / html / Sonat中导入“) 在进行一个项目/应用/配置/ config_dev.yml“)。

    在我评论jms_serializer配置后,我收到了另一个错误:

  2. [Symfony的\元器件\配置\定义\异常\ InvalidTypeException]
    路径“sonata_user.profile.dashboard.blocks.position”的类型无效。预期的数组,但得到了字符串

  3. 这是我的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:
    

    任何想法??

    编辑

    对于第二个错误,我尝试按如下方式编辑sonata_user.profile.dashboard.blocks

    blocks:
                    type:                 ~
                    settings:
                        position:             right
                        # Prototype
                    id:                   []
    

    我不确定这是否是正确的配置,但错误消失了。

    等待回应!

1 个答案:

答案 0 :(得分:0)

查看文档,该位置的缩进方式不同:

CLLocationManager

在你的位置上,位置就在id ...可能就是那个