fkooman\OAuth\Client\ClientConfig::__construct PHP Method

__construct() public method

public __construct ( array $data )
$data array
    public function __construct(array $data)
    {
        foreach (array('client_id', 'authorize_endpoint', 'token_endpoint') as $key) {
            if (!array_key_exists($key, $data)) {
                throw new ClientConfigException(sprintf("missing field '%s'", $key));
            }
        }
        $this->setClientId($data['client_id']);
        $this->setAuthorizeEndpoint($data['authorize_endpoint']);
        $this->setTokenEndpoint($data['token_endpoint']);
        $clientSecret = array_key_exists('client_secret', $data) ? $data['client_secret'] : null;
        $this->setClientSecret($clientSecret);
        $redirectUri = array_key_exists('redirect_uri', $data) ? $data['redirect_uri'] : null;
        $this->setRedirectUri($redirectUri);
        $credentialsInRequestBody = array_key_exists('credentials_in_request_body', $data) ? $data['credentials_in_request_body'] : false;
        $this->setCredentialsInRequestBody($credentialsInRequestBody);
        $defaultTokenType = array_key_exists('default_token_type', $data) ? $data['default_token_type'] : null;
        $this->setDefaultTokenType($defaultTokenType);
        $allowNullExpiresIn = array_key_exists('allow_null_expires_in', $data) ? $data['allow_null_expires_in'] : false;
        $this->setAllowNullExpiresIn($allowNullExpiresIn);
        $useRedirectUriOnRefreshTokenRequest = array_key_exists('use_redirect_uri_on_refresh_token_request', $data) ? $data['use_redirect_uri_on_refresh_token_request'] : false;
        $this->setUseRedirectUriOnRefreshTokenRequest($useRedirectUriOnRefreshTokenRequest);
        $defaultServerScope = array_key_exists('default_server_scope', $data) ? $data['default_server_scope'] : null;
        $this->setDefaultServerScope($defaultServerScope);
        $useCommaSeparatedScope = array_key_exists('use_comma_separated_scope', $data) ? $data['use_comma_separated_scope'] : null;
        $this->setUseCommaSeparatedScope($useCommaSeparatedScope);
        $useArrayScope = array_key_exists('use_array_scope', $data) ? $data['use_array_scope'] : null;
        $this->setUseArrayScope($useArrayScope);
        $enableDebug = array_key_exists('enable_debug', $data) ? $data['enable_debug'] : false;
        $this->setEnableDebug($enableDebug);
        $allowStringExpiresIn = array_key_exists('allow_string_expires_in', $data) ? $data['allow_string_expires_in'] : false;
        $this->setAllowStringExpiresIn($allowStringExpiresIn);
    }

Usage Example

Esempio n. 1
0
 public function __construct(array $data)
 {
     foreach (array('client_id', 'client_secret') as $key) {
         if (!isset($data[$key])) {
             throw new ClientConfigException(sprintf("missing field '%s'", $key));
         }
     }
     $clientData = array("client_id" => $data['client_id'], "client_secret" => $data['client_secret'], "authorize_endpoint" => "https://github.com/login/oauth/authorize", "token_endpoint" => "https://github.com/login/oauth/access_token", "use_comma_separated_scope" => true, "credentials_in_request_body" => true);
     parent::__construct($clientData);
 }
All Usage Examples Of fkooman\OAuth\Client\ClientConfig::__construct