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\SupplierRepositoryProtocol; |
17
|
|
|
use Administration\Domain\Supplier\Model\Supplier; |
18
|
|
|
use Administration\Infrastructure\Finders\Exceptions\SupplierNotFound; |
19
|
|
|
use Administration\Infrastructure\Supplier\SupplierModelMapper; |
20
|
|
|
use Doctrine\DBAL\Connection; |
|
|
|
|
21
|
|
|
use Doctrine\DBAL\Exception; |
|
|
|
|
22
|
|
|
|
23
|
|
|
class DoctrineSupplierRepository implements SupplierRepositoryProtocol |
24
|
|
|
{ |
25
|
|
|
protected Connection $connection; |
26
|
|
|
|
27
|
|
|
public function __construct(Connection $connection) |
28
|
|
|
{ |
29
|
|
|
$this->connection = $connection; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @throws Exception |
34
|
|
|
*/ |
35
|
|
|
public function existsWithName(string $name): bool |
36
|
|
|
{ |
37
|
|
|
$statement = $this->connection->createQueryBuilder() |
38
|
|
|
->select('name') |
39
|
|
|
->from('supplier') |
40
|
|
|
->where('name = :name') |
41
|
|
|
->setParameter('name', $name) |
42
|
|
|
->execute() |
43
|
|
|
->fetchOne() |
44
|
|
|
; |
45
|
|
|
|
46
|
|
|
return false !== $statement; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @throws Exception |
51
|
|
|
*/ |
52
|
|
|
public function add(Supplier $supplier): void |
53
|
|
|
{ |
54
|
|
|
$data = (new SupplierModelMapper())->getDataFromSupplier($supplier); |
55
|
|
|
|
56
|
|
|
$this->connection->createQueryBuilder() |
57
|
|
|
->insert('supplier') |
58
|
|
|
->values([ |
59
|
|
|
'uuid' => '?', 'name' => '?', 'address' => '?', 'zip_code' => '?', 'town' => '?', |
60
|
|
|
'country' => '?', 'phone' => '?', 'facsimile' => '?', 'email' => '?', 'contact_name' => '?', |
61
|
|
|
'cellphone' => '?', 'family_log' => '?', 'delay_delivery' => '?', 'order_days' => '?', 'slug' => '?', |
62
|
|
|
'active' => '?', |
63
|
|
|
]) |
64
|
|
|
->setParameters([ |
65
|
|
|
$data['uuid'], $data['name'], $data['address'], $data['zip_code'], $data['town'], |
66
|
|
|
$data['country'], $data['phone'], $data['facsimile'], $data['email'], $data['contact_name'], |
67
|
|
|
$data['cellphone'], $data['family_log'], $data['delay_delivery'], $data['order_days'], $data['slug'], |
68
|
|
|
$data['active'], |
69
|
|
|
]) |
70
|
|
|
->execute() |
71
|
|
|
; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @throws \Doctrine\DBAL\Driver\Exception|Exception |
76
|
|
|
*/ |
77
|
|
|
public function update(Supplier $supplier): void |
78
|
|
|
{ |
79
|
|
|
$data = (new SupplierModelMapper())->getDataFromSupplier($supplier); |
80
|
|
|
|
81
|
|
|
$this->connection->prepare( |
82
|
|
|
'UPDATE supplier SET |
83
|
|
|
uuid = :uuid, name = :name, address = :address, zip_code = :zip_code, town = :town, country = :country, phone = :phone, |
84
|
|
|
facsimile = :facsimile, email = :email, contact_name = :contact_name, cellphone = :cellphone, family_log = :family_log, |
85
|
|
|
delay_delivery = :delay_delivery, order_days = :order_days, slug = :slug, active = :active |
86
|
|
|
WHERE uuid = :uuid' |
87
|
|
|
)->execute($data); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @throws Exception |
92
|
|
|
*/ |
93
|
|
|
public function findOneByUuid(string $uuid): Supplier |
94
|
|
|
{ |
95
|
|
|
$result = $this->connection->createQueryBuilder() |
96
|
|
|
->select( |
97
|
|
|
'uuid', |
98
|
|
|
'name', |
99
|
|
|
'address', |
100
|
|
|
'zip_code', |
101
|
|
|
'town', |
102
|
|
|
'country', |
103
|
|
|
'phone', |
104
|
|
|
'facsimile', |
105
|
|
|
'email', |
106
|
|
|
'contact_name', |
107
|
|
|
'cellphone', |
108
|
|
|
'family_log', |
109
|
|
|
'delay_delivery', |
110
|
|
|
'order_days', |
111
|
|
|
'slug', |
112
|
|
|
'active' |
113
|
|
|
) |
114
|
|
|
->from('supplier') |
115
|
|
|
->where('uuid = :uuid') |
116
|
|
|
->setParameter('uuid', $uuid) |
117
|
|
|
->execute() |
118
|
|
|
->fetchAssociative() |
119
|
|
|
; |
120
|
|
|
|
121
|
|
|
if (null === $result) { |
122
|
|
|
throw new SupplierNotFound(); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
return (new SupplierModelMapper())->getDomainModelFromArray($result); |
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