|
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\Finders\Doctrine; |
|
15
|
|
|
|
|
16
|
|
|
use Administration\Application\Protocol\Finders\SettingsFinderProtocol; |
|
17
|
|
|
use Administration\Application\Settings\ReadModel\Settings as SettingsReadModel; |
|
18
|
|
|
use Administration\Domain\Settings\Model\VO\Currency; |
|
19
|
|
|
use Doctrine\DBAL\Connection; |
|
|
|
|
|
|
20
|
|
|
use Doctrine\DBAL\Exception; |
|
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
class DoctrineSettingsFinder implements SettingsFinderProtocol |
|
23
|
|
|
{ |
|
24
|
|
|
private Connection $connection; |
|
25
|
|
|
|
|
26
|
|
|
public function __construct(Connection $connection) |
|
27
|
|
|
{ |
|
28
|
|
|
$this->connection = $connection; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @throws \Doctrine\DBAL\Driver\Exception|Exception |
|
33
|
|
|
*/ |
|
34
|
|
|
public function findOne(): ?SettingsReadModel |
|
35
|
|
|
{ |
|
36
|
|
|
$query = <<<'SQL' |
|
37
|
|
|
SELECT |
|
38
|
|
|
settings.uuid as uuid, |
|
39
|
|
|
settings.currency as currency, |
|
40
|
|
|
settings.locale as locale |
|
41
|
|
|
FROM settings |
|
42
|
|
|
SQL; |
|
43
|
|
|
$result = $this->connection->executeQuery($query)->fetchAssociative(); |
|
44
|
|
|
|
|
45
|
|
|
if (false !== $result) { |
|
46
|
|
|
return $this->createSettings($result); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
return null; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @throws \Doctrine\DBAL\Driver\Exception|Exception |
|
54
|
|
|
*/ |
|
55
|
|
|
public function findByLocale(string $locale): ?SettingsReadModel |
|
56
|
|
|
{ |
|
57
|
|
|
$query = <<<'SQL' |
|
58
|
|
|
SELECT |
|
59
|
|
|
settings.uuid as uuid, |
|
60
|
|
|
settings.currency as currency, |
|
61
|
|
|
settings.locale as locale |
|
62
|
|
|
FROM settings |
|
63
|
|
|
WHERE locale = :locale |
|
64
|
|
|
SQL; |
|
65
|
|
|
$result = $this->connection->executeQuery($query, ['locale' => $locale])->fetchAssociative(); |
|
66
|
|
|
|
|
67
|
|
|
if (false !== $result) { |
|
68
|
|
|
return $this->createSettings($result); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
return null; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @throws \Doctrine\DBAL\Driver\Exception|Exception |
|
76
|
|
|
*/ |
|
77
|
|
|
public function findByCurrency(string $currency): ?SettingsReadModel |
|
78
|
|
|
{ |
|
79
|
|
|
$query = <<<'SQL' |
|
80
|
|
|
SELECT |
|
81
|
|
|
settings.uuid as uuid, |
|
82
|
|
|
settings.currency as currency, |
|
83
|
|
|
settings.locale as locale |
|
84
|
|
|
FROM settings |
|
85
|
|
|
WHERE currency = :currency |
|
86
|
|
|
SQL; |
|
87
|
|
|
$result = $this->connection->executeQuery($query, ['currency' => $currency])->fetchAssociative(); |
|
88
|
|
|
|
|
89
|
|
|
if (false !== $result) { |
|
90
|
|
|
return $this->createSettings($result); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
return null; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
private function createSettings(array $result): SettingsReadModel |
|
97
|
|
|
{ |
|
98
|
|
|
$symbol = Currency::fromString($result['currency']); |
|
99
|
|
|
|
|
100
|
|
|
return new SettingsReadModel( |
|
101
|
|
|
$result['currency'], |
|
102
|
|
|
$result['locale'], |
|
103
|
|
|
$symbol->symbol(), |
|
104
|
|
|
$result['uuid'] |
|
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