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\Domain\Model\VO\Currency; |
17
|
|
|
use Company\Domain\Model\VO\Locale; |
18
|
|
|
use Company\Domain\Storage\Settings\SettingsEntity; |
19
|
|
|
use Company\Infrastructure\Doctrine\Entity\Settings; |
20
|
|
|
use Core\Domain\Common\Model\VO\ResourceUuid; |
21
|
|
|
use Core\Domain\Common\Model\VO\ResourceUuidInterface; |
22
|
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; |
|
|
|
|
23
|
|
|
use Doctrine\ORM\NonUniqueResultException; |
|
|
|
|
24
|
|
|
use Doctrine\ORM\OptimisticLockException; |
|
|
|
|
25
|
|
|
use Doctrine\ORM\ORMException; |
|
|
|
|
26
|
|
|
use Doctrine\Persistence\ManagerRegistry; |
|
|
|
|
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @method Settings|null find($id, $lockMode = null, $lockVersion = null) |
30
|
|
|
* @method Settings|null findOneBy(array $criteria, array $orderBy = null) |
31
|
|
|
* @method Settings[] findAll() |
32
|
|
|
* @method Settings[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) |
33
|
|
|
*/ |
34
|
|
|
class SettingsRepository extends ServiceEntityRepository |
35
|
|
|
{ |
36
|
|
|
public function __construct(ManagerRegistry $registry) |
37
|
|
|
{ |
38
|
|
|
parent::__construct($registry, Settings::class); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @throws ORMException |
43
|
|
|
* @throws OptimisticLockException |
44
|
|
|
*/ |
45
|
|
|
public function save(SettingsEntity $settings): void |
46
|
|
|
{ |
47
|
|
|
$this->getEntityManager()->persist($settings); |
48
|
|
|
$this->flush(); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function flush(): void |
52
|
|
|
{ |
53
|
|
|
$this->getEntityManager()->flush(); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @throws ORMException |
58
|
|
|
*/ |
59
|
|
|
public function remove(SettingsEntity $settings): void |
60
|
|
|
{ |
61
|
|
|
$this->getEntityManager()->remove($settings); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @throws NonUniqueResultException |
66
|
|
|
*/ |
67
|
|
|
public function findOneByUuid(ResourceUuidInterface $uuid): ?Settings |
68
|
|
|
{ |
69
|
|
|
return $this->createQueryBuilder('ds') |
70
|
|
|
->where('ds.uuid = :uuid') |
71
|
|
|
->setParameter('uuid', ResourceUuid::fromUuid($uuid)) |
72
|
|
|
->getQuery() |
73
|
|
|
->getOneOrNullResult() |
74
|
|
|
; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @throws NonUniqueResultException |
79
|
|
|
*/ |
80
|
|
|
public function findByLocale(Locale $locale): ?Settings |
81
|
|
|
{ |
82
|
|
|
return $this->createQueryBuilder('ds') |
83
|
|
|
->where('ds.locale = :locale') |
84
|
|
|
->setParameter('locale', Locale::fromLocale($locale)) |
85
|
|
|
->getQuery() |
86
|
|
|
->getOneOrNullResult() |
87
|
|
|
; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @throws NonUniqueResultException |
92
|
|
|
*/ |
93
|
|
|
public function findByCurrency(Currency $currency): ?Settings |
94
|
|
|
{ |
95
|
|
|
return $this->createQueryBuilder('ds') |
96
|
|
|
->where('ds.currency = :currency') |
97
|
|
|
->setParameter('currency', Currency::fromCurrency($currency)) |
98
|
|
|
->getQuery() |
99
|
|
|
->getOneOrNullResult() |
100
|
|
|
; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @throws NonUniqueResultException |
105
|
|
|
*/ |
106
|
|
|
public function settingsExists(): bool |
107
|
|
|
{ |
108
|
|
|
$statement = $this->createQueryBuilder('ds') |
109
|
|
|
->getQuery() |
110
|
|
|
->getOneOrNullResult() |
111
|
|
|
; |
112
|
|
|
|
113
|
|
|
return null !== $statement; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @throws NonUniqueResultException |
118
|
|
|
* @Todo Replaced by findDefaultSettings |
119
|
|
|
*/ |
120
|
|
|
public function findOne(): ?Settings |
121
|
|
|
{ |
122
|
|
|
return $this->createQueryBuilder('ds') |
123
|
|
|
->getQuery() |
124
|
|
|
->getOneOrNullResult() |
125
|
|
|
; |
126
|
|
|
} |
127
|
|
|
} |
128
|
|
|
|
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