Skip to content

Commit

Permalink
Merge pull request #15 from qbhy/master
Browse files Browse the repository at this point in the history
修复抽象AccessToken类获取http实例问题
  • Loading branch information
Hanson authored Jun 11, 2020
2 parents 1ade721 + bee283e commit 46990dc
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions src/AbstractAccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ abstract class AbstractAccessToken
*/
protected $http;

/**
* @var Foundation
*/
protected $app;

/**
* Token string.
*
Expand All @@ -69,8 +74,17 @@ abstract class AbstractAccessToken
protected $token;

/**
* @param mixed $token
* @param int $expires
* AbstractAccessToken constructor.
* @param Foundation $app
*/
public function __construct(Foundation $app)
{
$this->app = $app;
}

/**
* @param mixed $token
* @param int $expires
* @return $this
*/
public function setToken($token, $expires = 86400)
Expand All @@ -87,7 +101,7 @@ public function setToken($token, $expires = 86400)
/**
* Get token from cache.
*
* @param bool $forceRefresh
* @param bool $forceRefresh
*
* @return string
*/
Expand Down Expand Up @@ -128,7 +142,7 @@ abstract public function getTokenFromServer();
abstract public function checkTokenResponse($result);

/**
* @param mixed $appId
* @param mixed $appId
*/
public function setAppId($appId)
{
Expand All @@ -144,7 +158,7 @@ public function getAppId()
}

/**
* @param string $secret
* @param string $secret
*/
public function setSecret($secret)
{
Expand All @@ -162,7 +176,7 @@ public function getSecret()
/**
* Set cache instance.
*
* @param \Doctrine\Common\Cache\Cache $cache
* @param \Doctrine\Common\Cache\Cache $cache
*
* @return AbstractAccessToken
*/
Expand Down Expand Up @@ -204,13 +218,13 @@ public function getCacheKey()
*/
public function getHttp()
{
return $this->http ?: $this->http = new Http();
return $this->http ?? $this->app->http;
}

/**
* Set the http instance.
*
* @param Http $http
* @param Http $http
*
* @return $this
*/
Expand Down

0 comments on commit 46990dc

Please sign in to comment.