This commit is contained in:
20 files changed
+135
-237
No files matched your search
@@ -4,20 +4,12 @@ use DateTime;
|
||||
use Generator;
|
||||
use SokoWeb\Database\Query\Select;
|
||||
use RVR\PersistentData\Model\OAuthToken;
|
||||
use SokoWeb\PersistentData\PersistentDataManager;
|
||||
|
||||
class OAuthTokenRepository
|
||||
{
|
||||
private PersistentDataManager $pdm;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->pdm = new PersistentDataManager();
|
||||
}
|
||||
|
||||
public function getById(int $id): ?OAuthToken
|
||||
{
|
||||
return $this->pdm->selectFromDbById($id, OAuthToken::class);
|
||||
return \Container::$persistentDataManager->selectFromDbById($id, OAuthToken::class);
|
||||
}
|
||||
|
||||
public function getByCode(string $code): ?OAuthToken
|
||||
@@ -25,7 +17,7 @@ class OAuthTokenRepository
|
||||
$select = new Select(\Container::$dbConnection);
|
||||
$select->where('code', '=', $code);
|
||||
|
||||
return $this->pdm->selectFromDb($select, OAuthToken::class);
|
||||
return \Container::$persistentDataManager->selectFromDb($select, OAuthToken::class);
|
||||
}
|
||||
|
||||
public function getByAccessToken(string $accessToken): ?OAuthToken
|
||||
@@ -33,7 +25,7 @@ class OAuthTokenRepository
|
||||
$select = new Select(\Container::$dbConnection);
|
||||
$select->where('access_token', '=', $accessToken);
|
||||
|
||||
return $this->pdm->selectFromDb($select, OAuthToken::class);
|
||||
return \Container::$persistentDataManager->selectFromDb($select, OAuthToken::class);
|
||||
}
|
||||
|
||||
public function getAllExpired(): Generator
|
||||
@@ -41,6 +33,6 @@ class OAuthTokenRepository
|
||||
$select = new Select(\Container::$dbConnection);
|
||||
$select->where('expires', '<', (new DateTime())->format('Y-m-d H:i:s'));
|
||||
|
||||
yield from $this->pdm->selectMultipleFromDb($select, OAuthToken::class);
|
||||
yield from \Container::$persistentDataManager->selectMultipleFromDb($select, OAuthToken::class);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user