Symfony 3.3 ( HWIOAuthBundle + FOSUserBundle) 在参数中发现无效键 "user_manager"
Symfony 3.3 ( HWIOAuthBundle + FOSUserBundle) Invalid key "user_manager" found in arguments
我刚刚更新到 Symfony 3.3,现在我收到错误消息:
Invalid key "user_manager" found in arguments of method
"__construct()" for service "app.fos_user.oauth_provider": only
integer or $named arguments are allowed.
我不明白这个问题的原因,这是我的配置:
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
之前一切正常。
谢谢你帮助我。
您的服务组织不当,因为您应该将 fos.user_manager 服务和 facebook.[= 作为参数传递11=]
尝试将您的 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}]
我刚刚更新到 Symfony 3.3,现在我收到错误消息:
Invalid key "user_manager" found in arguments of method "__construct()" for service "app.fos_user.oauth_provider": only integer or $named arguments are allowed.
我不明白这个问题的原因,这是我的配置:
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
之前一切正常。
谢谢你帮助我。
您的服务组织不当,因为您应该将 fos.user_manager 服务和 facebook.[= 作为参数传递11=]
尝试将您的 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}]