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