getInstance() public static method

Returns an instance to OAuth2 server based on the current configuration.
public static getInstance ( string $key ) : array | OAuth2
$key string Unique identifier for the OAuth2 server that you wish to get.
return array | OAuth2
Example #1
0
 /**
  * Base constructor.
  *
  * @param string $serverName  Name of the OAuth2 server in the current configuration.
  * @param string|array $roles Roles that will be set for the OAuth2 users.
  *
  * @throws OAuth2Exception
  */
 public function __construct($serverName, $roles)
 {
     try {
         $this->oauth2Instance = OAuth2Loader::getInstance($serverName);
         $this->oauth2Roles = (array) $roles;
     } catch (\Exception $e) {
         throw new OAuth2Exception($e->getMessage());
     }
 }
Example #2
0
 /**
  * @expectedException \Webiny\Component\OAuth2\OAuth2Exception
  * @expectedExceptionMessage Server missing
  */
 public function testGetInstanceServerException()
 {
     OAuth2Loader::getInstance('GPlus');
 }
Example #3
0
 public function dataProvider()
 {
     OAuth2::setConfig(realpath(__DIR__ . '/' . self::CONFIG));
     Request::getInstance()->setCurrentUrl('http://admin.w3.com/batman-is-better-than-superman/?batman=one&superman=two');
     $oauth2Instance = OAuth2Loader::getInstance('Facebook');
     $oauth2Request = new OAuth2Request($oauth2Instance);
     return [[$oauth2Request]];
 }