0

We are using HWIOAuhtBundle for authentication so have a such user provider interface:

    class OAuthUserProvider implements 
          UserProviderInterface , OAuthAwareUserProviderInterface
    {
      ...
      public function loadUserByUsername($username)
      {
         ...
      }
      public function loadUserByOAuthUserResponse(UserResponseInterface $response)
      {
         ...
      }
   }

Is there the way to access parameters specified in config.yml in methods of OAuthUserProvider class, for instance the facebook app id?

hwi_oauth:
    resource_owners:
        facebook:
            type:                facebook
            client_id:           %fb_app%

or how to access the ServiceContainer? And then get parms this way: http://symfony.com/doc/current/components/dependency_injection/parameters.html

ChatCloud
  • 1,152
  • 2
  • 8
  • 22

1 Answers1

0

It's possible to pass it as a parameter of OAuthUserProvider constructor.

1)Add an argument to the service with a correct parameter name.

;services.yml

services:
     my_user.oauth_user_provider: 
         class: %my_user.oauth_user_provider.class%
         arguments: [%facebook_secret%]

2)Add an argument to the class ctor.

//OAuthUserProvider.php

class OAuthUserProvider implements 
      UserProviderInterface , OAuthAwareUserProviderInterface
{
    public function __construct($secret)
    {
       ...
    }
...
}
ChatCloud
  • 1,152
  • 2
  • 8
  • 22