-
Notifications
You must be signed in to change notification settings - Fork 13
/
RefreshTokenRepository.php
45 lines (37 loc) · 1.14 KB
/
RefreshTokenRepository.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace App\Application\Repository\Doctrine;
use App\Domain\Model\RefreshToken;
use App\Domain\Repository\AccessTokenRepositoryInterface;
use Doctrine\Common\Persistence\ObjectRepository;
use Doctrine\ORM\EntityManagerInterface;
final class RefreshTokenRepository implements AccessTokenRepositoryInterface
{
private const ENTITY = RefreshToken::class;
/**
* @var EntityManagerInterface
*/
private $entityManager;
/**
* @var ObjectRepository
*/
private $objectRepository;
/**
* UserRepository constructor.
* @param EntityManagerInterface $entityManager
*/
public function __construct(
EntityManagerInterface $entityManager
) {
$this->entityManager = $entityManager;
$this->objectRepository = $this->entityManager->getRepository(self::ENTITY);
}
public function find(string $accessTokenId): ?RefreshToken
{
return $this->entityManager->find(self::ENTITY, $accessTokenId);
}
public function save(RefreshToken $accessToken): void
{
$this->entityManager->persist($accessToken);
$this->entityManager->flush();
}
}