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 User\Infrastructure\Doctrine\Repository; |
15
|
|
|
|
16
|
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; |
|
|
|
|
17
|
|
|
use Doctrine\ORM\NonUniqueResultException; |
|
|
|
|
18
|
|
|
use Doctrine\ORM\OptimisticLockException; |
|
|
|
|
19
|
|
|
use Doctrine\ORM\ORMException; |
|
|
|
|
20
|
|
|
use Doctrine\Persistence\ManagerRegistry; |
|
|
|
|
21
|
|
|
use User\Infrastructure\Doctrine\Entity\User; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @method User|null find($id, $lockMode = null, $lockVersion = null) |
25
|
|
|
* @method User|null findOneBy(array $criteria, array $orderBy = null) |
26
|
|
|
* @method User[] findAll() |
27
|
|
|
* @method User[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) |
28
|
|
|
*/ |
29
|
|
|
class UserRepository extends ServiceEntityRepository |
30
|
|
|
{ |
31
|
|
|
public function __construct(ManagerRegistry $registry) |
32
|
|
|
{ |
33
|
|
|
parent::__construct($registry, User::class); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @throws NonUniqueResultException |
38
|
|
|
*/ |
39
|
|
|
final public function existWithUsername(string $username): bool |
40
|
|
|
{ |
41
|
|
|
$statement = $this->createQueryBuilder('u') |
42
|
|
|
->select(['1']) |
43
|
|
|
->where('u.username = :username') |
44
|
|
|
->setParameter('username', $username) |
45
|
|
|
->getQuery() |
46
|
|
|
->getOneOrNullResult() |
47
|
|
|
; |
48
|
|
|
|
49
|
|
|
return null !== $statement; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @throws NonUniqueResultException |
54
|
|
|
*/ |
55
|
|
|
final public function existWithEmail(string $email): bool |
56
|
|
|
{ |
57
|
|
|
$statement = $this->createQueryBuilder('u') |
58
|
|
|
->select(['1']) |
59
|
|
|
->where('u.email = :email') |
60
|
|
|
->setParameter('email', $email) |
61
|
|
|
->getQuery() |
62
|
|
|
->getOneOrNullResult() |
63
|
|
|
; |
64
|
|
|
|
65
|
|
|
return null !== $statement; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @throws ORMException |
70
|
|
|
* @throws OptimisticLockException |
71
|
|
|
*/ |
72
|
|
|
final public function save(User $user): void |
73
|
|
|
{ |
74
|
|
|
$this->getEntityManager()->persist($user); |
75
|
|
|
$this->getEntityManager()->flush(); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @throws OptimisticLockException |
80
|
|
|
* @throws ORMException |
81
|
|
|
*/ |
82
|
|
|
public function flush(): void |
83
|
|
|
{ |
84
|
|
|
$this->getEntityManager()->flush(); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @throws ORMException |
89
|
|
|
*/ |
90
|
|
|
final public function remove(User $user): void |
91
|
|
|
{ |
92
|
|
|
$this->getEntityManager()->remove($user); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @throws NonUniqueResultException |
97
|
|
|
*/ |
98
|
|
|
final public function findOneByUuid(string $uuid): ?User |
99
|
|
|
{ |
100
|
|
|
return $this->createQueryBuilder('u') |
101
|
|
|
->where('u.uuid = :uuid') |
102
|
|
|
->setParameter('uuid', $uuid) |
103
|
|
|
->getQuery() |
104
|
|
|
->getOneOrNullResult() |
105
|
|
|
; |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|
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