2015-03-31 36 views
0

我在我的config.yml中有一些設置,我想將其作爲參數傳遞給services.yml中的服務。將config.yml設置注入服務

#config.yml 
hwi_oauth: 
resource_owners: 
     facebook: 
      type:    facebook 
      client_id:   %facebook_app_id% 
      client_secret:  %facebook_app_secret% 
      scope:    "email, public_profile, user_friends" 
      infos_url:  "https://graph.facebook.com/me?fields=id,name,email,picture.type(square)" 
      paths: 
       email:   email 
       profilepicture: picture.data.url 
      options: 
       display: popup #dialog is optimized for popup window 


#services.yml 
hwi_oauth.resource_owner.facebook: 
     class: AppBundle\OAuth\ResourceOwner\FacebookResourceOwner 
     arguments: ['@hwi_oauth.http_client','@security.http_utils',**{INJECT HERE}**,'@hwi_oauth.storage.session'] 

我該怎麼做?

回答

1

將這些值作爲參數。您可以將參數注入服務。

+0

有沒有辦法做到這一點,而無需手動輸入......?在config.yml中有什麼意義,然後 – Chris 2015-03-31 18:01:47

+0

參數是機器特定的選項,配置應該是特定於環境的。您可以從擴展設置參數: /bundles/prepend_extension.html – Greg 2015-03-31 18:08:39