|
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\SettingsRepositoryProtocol; |
|
17
|
|
|
use Administration\Domain\Settings\Model\Settings; |
|
18
|
|
|
use Administration\Infrastructure\Settings\Mapper\SettingsModelMapper; |
|
19
|
|
|
use Doctrine\DBAL\Connection; |
|
|
|
|
|
|
20
|
|
|
use Doctrine\DBAL\Exception; |
|
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
class DoctrineSettingsRepository implements SettingsRepositoryProtocol |
|
23
|
|
|
{ |
|
24
|
|
|
protected Connection $connection; |
|
25
|
|
|
|
|
26
|
|
|
public function __construct(Connection $connection) |
|
27
|
|
|
{ |
|
28
|
|
|
$this->connection = $connection; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @throws Exception |
|
33
|
|
|
*/ |
|
34
|
|
|
final public function add(Settings $settings): void |
|
35
|
|
|
{ |
|
36
|
|
|
$data = (new SettingsModelMapper())->getDataFromSettings($settings); |
|
37
|
|
|
|
|
38
|
|
|
$query = $this->connection->createQueryBuilder() |
|
39
|
|
|
->insert('settings') |
|
40
|
|
|
->values(['uuid' => '?', 'currency' => '?', 'locale' => '?']) |
|
41
|
|
|
->setParameters([$data['uuid'], $data['currency'], $data['locale']]) |
|
42
|
|
|
; |
|
43
|
|
|
$query->execute(); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @throws Exception |
|
48
|
|
|
*/ |
|
49
|
|
|
final public function update(Settings $settings): void |
|
50
|
|
|
{ |
|
51
|
|
|
$data = (new SettingsModelMapper())->getDataFromSettings($settings); |
|
52
|
|
|
|
|
53
|
|
|
$query = $this->connection->createQueryBuilder() |
|
54
|
|
|
->update('settings') |
|
55
|
|
|
->set('currency', '?') |
|
56
|
|
|
->set('locale', '?') |
|
57
|
|
|
->where('uuid = ?') |
|
58
|
|
|
->setParameters([0 => $data['currency'], 1 => $data['locale'], 2 => $settings->uuid()]) |
|
59
|
|
|
; |
|
60
|
|
|
$query->execute(); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @throws Exception |
|
65
|
|
|
*/ |
|
66
|
|
|
final public function findOneByUuid(string $uuid): ?Settings |
|
67
|
|
|
{ |
|
68
|
|
|
$query = $this->connection->createQueryBuilder() |
|
69
|
|
|
->select('uuid', 'currency', 'locale') |
|
70
|
|
|
->from('settings') |
|
71
|
|
|
->where('uuid = ?') |
|
72
|
|
|
->setParameter(0, $uuid) |
|
73
|
|
|
; |
|
74
|
|
|
$result = $query->execute()->fetchAssociative(); |
|
75
|
|
|
|
|
76
|
|
|
return (new SettingsModelMapper())->getDomainModelFromArray($result); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @throws Exception |
|
81
|
|
|
*/ |
|
82
|
|
|
final public function exists(): bool |
|
83
|
|
|
{ |
|
84
|
|
|
$query = $this->connection->createQueryBuilder() |
|
85
|
|
|
->select('uuid') |
|
86
|
|
|
->from('settings') |
|
87
|
|
|
; |
|
88
|
|
|
|
|
89
|
|
|
$statement = $query->execute()->fetchAssociative(); |
|
90
|
|
|
|
|
91
|
|
|
return false !== $statement; |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|
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