symfony中的provider和chain_provider问题

时间:2012-09-17 01:59:58

标签: symfony provider

我收到以下错误,代码如下:

ServiceNotFoundException: The service "security.firewall.map.context.main" has a dependency on a non-existent service "security.user.provider.concrete.fos_user_bundle".

这是在我添加chain_provider:提供程序后发生的,如果我将其删除,它就可以正常运行。知道为什么吗?

security: 
    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

    providers:
        fos_userbundle:
            id: fos_user.user_provider.username_email
        my_fos_facebook_provider:
            id: my.facebook.user
        chain_provider:
            chain:
                providers: [fos_user_bundle, my_fos_facebook_provider]
        in_memory:
            memory:
                users:
                    user:  { password: userpass, roles: [ 'ROLE_USER' ] }
                    admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] }

    encoders:
        FOS\UserBundle\Model\UserInterface: sha512

    firewalls:
        main:
            pattern: ^/.*
            form_login:
                login_path: fos_user_security_login
                check_path: fos_user_security_check   
                provider: fos_userbundle
            fos_facebook:
                app_url: "http://apps.facebook.com/myapp/"
                server_url: "http://localhost/Symfony/web/app_dev.php"
                login_path: fos_user_security_login
                check_path: fos_user_security_check
                default_target_path: /
                provider: my_fos_facebook_provider
            anonymous: true
            logout: 
                path:   /logout
                target: / 
                handlers: ["fos_facebook.logout_handler"]
            #http_basic:
            #    realm: "Secured Demo Area"
        login:
            pattern:  ^/login$
            security: false

2 个答案:

答案 0 :(得分:2)

这是FOSFacebookBundle文档中的一个错误。您必须使用fos_userbundle和NOT fos_user_bundle(注意下划线)作为提供者名称。

答案 1 :(得分:0)

你添加'my_fos_facebook_provider'了吗?你必须将它绑定到'my.facebook.user service'(最后2行):

    providers:
        chainprovider:
            chain:
                providers: [fos_userbundle, my_fos_facebook_provider]
    fos_userbundle:
        id: fos_user.user_provider.username
    my_fos_facebook_provider:
        id: my.facebook.user