/** * 静态方法, 单例统一访问入口 * @return object 返回对象的唯一实例 */ public static function getInstance() { if (is_null(self::$_instance) || !isset(self::$_instance)) { self::$_instance = new self(); } return self::$_instance; }
/** * Overrides OAuth2::setRefreshToken() */ protected function setRefreshToken($oauthToken, $refreshToken, $clientId, $expires, $scope = NULL) { MiniRefreshToken::getInstance()->create($oauthToken, $refreshToken, $clientId, $expires, $scope); }
/** * 根据设备删除Token * @param int $deviceId */ public function deleteToken($deviceId) { $tokenObjects = OTokens::model()->findAll("device_id=:deviceId", array("deviceId" => $deviceId)); if (isset($tokenObjects)) { foreach ($tokenObjects as $tokenObject) { $token = $tokenObject["oauth_token"]; //删除refresh_token MiniRefreshToken::getInstance()->deleteToken($token); if ($this->hasCache) { //清理一级缓存 $key = $this->getCacheKey($token); $this->deleteCache($key); } //清理数据库记录 $tokenObject->delete(); } } }