【问题标题】:Symfony 3.3 ( HWIOAuthBundle + FOSUserBundle) Invalid key "user_manager" found in argumentsSymfony 3.3(HWIOAuthBundle + FOSUserBundle)在参数中发现无效的键“user_manager”
【发布时间】:2017-10-02 13:38:44
【问题描述】:

我刚刚更新到 Symfony 3.3,现在我收到了错误消息:

在方法的参数中发现无效的键“user_manager” 服务“app.fos_user.oauth_provider”的“__construct()”:仅 允许使用整数或 $named 参数。

我不明白这个问题的原因,这是我的配置:

service.yml # app/config/service.yml

app.fos_user.oauth_provider:
        class: EC\UserBundle\Entity\FOSUBUserProvider
        arguments:
            user_manager: "@fos_user.user_manager"
            user_response:
                facebook: facebook_id

config.yml

# app/config/config.yml

# FOSUserBundle Configuration
fos_user:
    db_driver: orm 
    firewall_name: main 
    user_class: EC\UserBundle\Entity\User 
    use_username_form_type: false

    registration:
        form:
            type: EC\UserBundle\Form\RegistrationType
    profile:
        form:
            type: EC\UserBundle\Form\ProfileFormType

    from_email:
        address: contact@xxxxxxxx.fr
        sender_name: xxxxxxxxx

#HWIOAuthBundle
hwi_oauth:
    firewall_names: ["main"]
    fosub:
        username_iterations: 30
        properties:
            facebook: facebook_id
    resource_owners:

        facebook:
            type:           facebook
            client_id:      "%facebook_client_id%"
            client_secret:  "%facebook_secret%"
            scope:         email
            infos_url:     "https://graph.facebook.com/me?fields=id,email,gender,last_name,first_name,birthday,picture.type(square)"
            options:
                crsf: true

security.yml

# app/config/security.yml
security:

    encoders:
        EC\UserBundle\Entity\User: sha512

    role_hierarchy:
        ROLE_ADMIN: ROLE_USER
        ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWER_TO_SWITCH]


    providers:
        main:
            id: fos_user.user_provider.username_email

    firewalls:

        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false

        main:
            pattern: ^/
            anonymous: true

            provider: main

            form_login: 
                login_path: fos_user_security_login
                check_path: fos_user_security_check

            logout:
                path: fos_user_security_logout
                target: /

            remember_me:
                secret: %secret% 

            #HWIOAuthBundle
            oauth:
                resource_owners:
                    facebook: "/connect/check-facebook"

                login_path:     /login
                failure_path:   /login

                oauth_user_provider:
                    service: app.fos_user.oauth_provider

在一切正常之前。

谢谢你帮助我。

【问题讨论】:

  • 您将服务定义与配置混淆了。查看文档中的容器章节,了解您遇到的各种问题。
  • @Cerad ,对不起,我不明白你的回答,尤其是它曾经有效,现在不再有效。
  • 不。没有那个服务定义。下面的答案部分解决了这个问题,但我相信你会遇到更多。
  • 嗨@Cerad,感谢您抽出宝贵时间回答。我理解你的意思,但现在下面的解决方案正在工作,即使我没有得到它可以完美完成的一切。

标签: php symfony fosuserbundle hwioauthbundle


【解决方案1】:

您的服务没有组织良好,因为您应该将 fos.user_manager 服务和 facebook 作为参数传递。

尝试将您的 service.yml 中的用户提供程序编辑为:

hwi_oauth.user.provider.entity:
    class: EC\UserBundle\Entity\FOSUBUserProvider
    #this is the place where the properties are passed to the UserProvider - see config.yml
    arguments: ['@fos_user.user_manager',{facebook: facebook_id}]

【讨论】:

    猜你喜欢
    • 2017-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-18
    • 1970-01-01
    • 2014-07-31
    • 1970-01-01
    相关资源
    最近更新 更多