1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the G.L.S.R. Apps package. |
7
|
|
|
* |
8
|
|
|
* (c) Dev-Int Création <[email protected]>. |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Administration\Infrastructure\Persistence\DoctrineOrm\Repositories; |
15
|
|
|
|
16
|
|
|
use Administration\Domain\Protocol\Repository\UserRepositoryProtocol; |
17
|
|
|
use Administration\Domain\User\Model\User; |
18
|
|
|
use Core\Domain\Model\User as UserSymfony; |
19
|
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; |
|
|
|
|
20
|
|
|
use Doctrine\ORM\NonUniqueResultException; |
|
|
|
|
21
|
|
|
use Doctrine\ORM\OptimisticLockException; |
|
|
|
|
22
|
|
|
use Doctrine\ORM\ORMException; |
|
|
|
|
23
|
|
|
use Doctrine\Persistence\ManagerRegistry; |
|
|
|
|
24
|
|
|
|
25
|
|
|
class DoctrineUserRepository extends ServiceEntityRepository implements UserRepositoryProtocol |
26
|
|
|
{ |
27
|
|
|
public function __construct(ManagerRegistry $registry) |
28
|
|
|
{ |
29
|
|
|
parent::__construct($registry, UserSymfony::class); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @throws ORMException |
34
|
|
|
* @throws OptimisticLockException |
35
|
|
|
*/ |
36
|
|
|
final public function add(User $user): void |
37
|
|
|
{ |
38
|
|
|
$this->getEntityManager()->persist($user); |
39
|
|
|
$this->getEntityManager()->flush(); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @throws ORMException |
44
|
|
|
*/ |
45
|
|
|
final public function remove(User $user): void |
46
|
|
|
{ |
47
|
|
|
$this->getEntityManager()->remove($user); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @throws NonUniqueResultException |
52
|
|
|
*/ |
53
|
|
|
final public function findOneByUuid(string $uuid): ?UserSymfony |
54
|
|
|
{ |
55
|
|
|
return $this->createQueryBuilder('u') |
56
|
|
|
->where('u.uuid = :uuid') |
57
|
|
|
->setParameter('uuid', $uuid) |
58
|
|
|
->getQuery() |
59
|
|
|
->getOneOrNullResult() |
60
|
|
|
; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @throws NonUniqueResultException |
65
|
|
|
*/ |
66
|
|
|
final public function existWithUsername(string $username): bool |
67
|
|
|
{ |
68
|
|
|
$statement = $this->createQueryBuilder('u') |
69
|
|
|
->select(['1']) |
70
|
|
|
->where('u.username = :username') |
71
|
|
|
->setParameter('username', $username) |
72
|
|
|
->getQuery() |
73
|
|
|
->getOneOrNullResult() |
74
|
|
|
; |
75
|
|
|
|
76
|
|
|
return !(null === $statement); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @throws NonUniqueResultException |
81
|
|
|
*/ |
82
|
|
|
final public function existWithEmail(string $email): bool |
83
|
|
|
{ |
84
|
|
|
$statement = $this->createQueryBuilder('u') |
85
|
|
|
->select(['1']) |
86
|
|
|
->where('u.email = :email') |
87
|
|
|
->setParameter('email', $email) |
88
|
|
|
->getQuery() |
89
|
|
|
->getOneOrNullResult() |
90
|
|
|
; |
91
|
|
|
|
92
|
|
|
return !(null === $statement); |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths