Переделал проверку на try/catch

This commit is contained in:
Artem Vasilev 2024-03-08 02:19:04 +03:00
parent 78486a87a8
commit 6089848c68

View File

@ -42,10 +42,17 @@ class AccessTokenRepository implements AccessTokenRepositoryInterface
public function persistNewAccessToken(AccessTokenEntityInterface $accessTokenEntity): void public function persistNewAccessToken(AccessTokenEntityInterface $accessTokenEntity): void
{ {
/** @var AccessToken $accessTokenEntity */ $found = false;
$accessToken = $this->accessTokenModel->getItemByIdentifier($accessTokenEntity->getIdentifier()); try {
/** @var AccessToken $accessTokenEntity */
$accessToken = $this->accessTokenModel->getItemByIdentifier($accessTokenEntity->getIdentifier());
if ($accessToken->id > 0) {
$found = true;
}
} catch (\Throwable $e) {
}
if ($accessToken->id > 0) { if ($found) {
throw UniqueTokenIdentifierConstraintViolationException::create(); throw UniqueTokenIdentifierConstraintViolationException::create();
} }