Skip to content
This repository has been archived by the owner on Feb 17, 2020. It is now read-only.

Commit

Permalink
- Renamed app to consumer
Browse files Browse the repository at this point in the history
  • Loading branch information
akadlec committed Mar 6, 2015
1 parent 8ea085b commit 510fdd2
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions docs/en/index.md
Expand Up @@ -31,12 +31,12 @@ extensions:

### Basic configuration

This extension creates a special section for configuration for your NEON configuration file. The absolute minimal configuration is appId and appSecret.
This extension creates a special section for configuration for your NEON configuration file. The absolute minimal configuration is consumerKey and consumerSecret.

```neon
twitter
appKey : "123456789"
appSecret : "e807f1fcf82d132f9bb018ca6738a19f"
consumerKey : "123456789"
consumerSecret : "e807f1fcf82d132f9bb018ca6738a19f"
```

### Authentication
Expand Down
14 changes: 7 additions & 7 deletions src/IPub/Twitter/Configuration.php
Expand Up @@ -30,12 +30,12 @@ class Configuration extends Nette\Object
/**
* @var string
*/
public $appKey;
public $consumerKey;

/**
* @var string
*/
public $appSecret;
public $consumerSecret;

/**
* @var array
Expand All @@ -47,13 +47,13 @@ class Configuration extends Nette\Object
];

/**
* @param string $appKey
* @param string $appSecret
* @param string $consumerKey
* @param string $consumerSecret
*/
public function __construct($appKey, $appSecret)
public function __construct($consumerKey, $consumerSecret)
{
$this->appKey = $appKey;
$this->appSecret = $appSecret;
$this->consumerKey = $consumerKey;
$this->consumerSecret = $consumerSecret;
}

/**
Expand Down
14 changes: 7 additions & 7 deletions src/IPub/Twitter/DI/TwitterExtension.php
Expand Up @@ -32,8 +32,8 @@ class TwitterExtension extends DI\CompilerExtension
* @var array
*/
protected $defaults = [
'appKey' => NULL,
'appSecret' => NULL,
'consumerKey' => NULL,
'consumerSecret' => NULL,
'clearAllWithLogout' => TRUE,
];

Expand All @@ -42,19 +42,19 @@ public function loadConfiguration()
$config = $this->getConfig($this->defaults);
$builder = $this->getContainerBuilder();

Utils\Validators::assert($config['appKey'], 'string', 'Application key');
Utils\Validators::assert($config['appSecret'], 'string', 'Application secret');
Utils\Validators::assert($config['consumerKey'], 'string', 'Application key');
Utils\Validators::assert($config['consumerSecret'], 'string', 'Application secret');

// Create oAuth consumer
$consumer = new IPub\OAuth\Consumer($config['appKey'], $config['appSecret']);
$consumer = new IPub\OAuth\Consumer($config['consumerKey'], $config['consumerSecret']);

$builder->addDefinition($this->prefix('client'))
->setClass('IPub\Twitter\Client', [$consumer]);

$builder->addDefinition($this->prefix('config'))
->setClass('IPub\Twitter\Configuration', [
$config['appKey'],
$config['appSecret'],
$config['consumerKey'],
$config['consumerSecret'],
]);

$builder->addDefinition($this->prefix('session'))
Expand Down
2 changes: 1 addition & 1 deletion src/IPub/Twitter/SessionStorage.php
Expand Up @@ -44,7 +44,7 @@ class SessionStorage extends Nette\Object
*/
public function __construct(Http\Session $session, Configuration $config)
{
$this->session = $session->getSection('Twitter/' . $config->appKey);
$this->session = $session->getSection('Twitter/' . $config->consumerKey);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/IPubTests/Twitter/ConfigurationTest.phpt
Expand Up @@ -42,12 +42,12 @@ class ConfigurationTest extends Tester\TestCase
Assert::match('https://api.twitter.com/1.1/account/verify_credentials.json', (string) $this->config->createUrl('api', 'account/verify_credentials.json'));

Assert::match('https://api.twitter.com/oauth/access_token?oauth_consumer_key=123&oauth_signature_method=HMAC-SHA1', (string) $this->config->createUrl('oauth', 'access_token', array(
'oauth_consumer_key' => $this->config->appKey,
'oauth_consumer_key' => $this->config->consumerKey,
'oauth_signature_method' => 'HMAC-SHA1'
)));

Assert::match('https://api.twitter.com/oauth/request_token?oauth_consumer_key=123&oauth_signature_method=HMAC-SHA1', (string) $this->config->createUrl('oauth', 'request_token', array(
'oauth_consumer_key' => $this->config->appKey,
'oauth_consumer_key' => $this->config->consumerKey,
'oauth_signature_method' => 'HMAC-SHA1'
)));
}
Expand Down
4 changes: 2 additions & 2 deletions tests/IPubTests/Twitter/files/config.neon
Expand Up @@ -2,5 +2,5 @@ extensions:
oauth: \IPub\OAuth\DI\OAuthExtension

twitter:
appKey: "93fc0e0480a89a6140e2"
appSecret: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
consumerKey: "93fc0e0480a89a6140e2"
consumerSecret: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"

0 comments on commit 510fdd2

Please sign in to comment.