OAuth2\OAuth2::setVariable PHP Method

setVariable() public method

Sets a persistent variable.
public setVariable ( string $name, mixed $value ) : OAuth2
$name string The name of the variable to set.
$value mixed The value to set.
return OAuth2 The application (for chained calls of this method)
    public function setVariable($name, $value)
    {
        $name = strtolower($name);
        $this->conf[$name] = $value;
        return $this;
    }

Usage Example

 /**
  * Tests OAuth2->grantAccessToken() with successful Auth code grant, but without redreict_uri in the input
  */
 public function testGrantAccessTokenWithGrantAuthCodeSuccessWithoutRedirect()
 {
     $request = new Request(array('grant_type' => OAuth2::GRANT_TYPE_AUTH_CODE, 'client_id' => 'my_little_app', 'client_secret' => 'b', 'code' => 'foo'));
     $storedToken = new OAuth2AuthCode('my_little_app', '', time() + 60, null, null, 'http://www.example.com');
     $mockStorage = $this->createBaseMock('OAuth2\\IOAuth2GrantCode');
     $mockStorage->expects($this->any())->method('getAuthCode')->will($this->returnValue($storedToken));
     $this->fixture = new OAuth2($mockStorage);
     $this->fixture->setVariable(OAuth2::CONFIG_ENFORCE_INPUT_REDIRECT, false);
     $response = $this->fixture->grantAccessToken($request);
     // Successful token grant will return a JSON encoded token:
     $this->assertRegexp('/{"access_token":".*","expires_in":\\d+,"token_type":"bearer"/', $response->getContent());
 }
All Usage Examples Of OAuth2\OAuth2::setVariable