Skip to content

Commit

Permalink
升级依赖,优化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
justmd5 committed Mar 17, 2019
1 parent 8ec6fbe commit 1926317
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"require": {
"php": ">=7.0",
"hanson/foundation-sdk": "^2.0 || ^3.0",
"hanson/foundation-sdk": "^3.0",
"ext-json": "*"
}
}
4 changes: 2 additions & 2 deletions src/Oauth/Oauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public function __construct(PinDuoDuo $app)
public function createAuthorization($token, $expires = 86399)
{
$accessToken = new AccessToken(
$this->app['config']['client_id'],
$this->app['config']['client_secret']
$this->app->getConfig('client_id'),
$this->app->getConfig('client_secret')
);

$accessToken->setToken($token, $expires);
Expand Down
2 changes: 1 addition & 1 deletion src/Oauth/PreAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private function accessToken()
*/
public function authorizationUrl($state = null, $view = null)
{
return self::AUTHORIZE_API_ARR[strtoupper($this->app['config']->get('member_type'))].http_build_query([
return self::AUTHORIZE_API_ARR[strtoupper($this->app->getConfig('member_type'))].http_build_query([
'client_id' => $this->accessToken()->getClientId(),
'response_type' => 'code',
'state' => $state,
Expand Down
9 changes: 5 additions & 4 deletions src/Oauth/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Justmd5\PinDuoDuo\Oauth;

use Hanson\Foundation\Foundation;
use Pimple\Container;
use Pimple\ServiceProviderInterface;

Expand All @@ -22,15 +23,15 @@ class ServiceProvider implements ServiceProviderInterface
*/
public function register(Container $pimple)
{
$pimple['oauth.access_token'] = function ($pimple) {
$pimple['oauth.access_token'] = function (Foundation $pimple) {
$accessToken = new AccessToken(
$pimple['config']['client_id'],
$pimple['config']['client_secret']
$pimple->getConfig('client_id'),
$pimple->getConfig('client_secret')
);

$accessToken->setRequest($pimple['request']);

$accessToken->setRedirectUri($pimple['config']->get('redirect_uri'));
$accessToken->setRedirectUri($pimple->getConfig('redirect_uri'));

return $accessToken;
};
Expand Down
7 changes: 4 additions & 3 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Justmd5\PinDuoDuo;

use Hanson\Foundation\Foundation;
use Pimple\Container;
use Pimple\ServiceProviderInterface;

Expand All @@ -22,10 +23,10 @@ class ServiceProvider implements ServiceProviderInterface
*/
public function register(Container $pimple)
{
$pimple['access_token'] = function ($pimple) {
$pimple['access_token'] = function (Foundation $pimple) {
return new AccessToken(
$pimple['config']['client_id'],
$pimple['config']['client_secret']
$pimple->getConfig('client_id'),
$pimple->getConfig('client_secret')
);
};

Expand Down

0 comments on commit 1926317

Please sign in to comment.