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\Domain\Supplier\Handler; |
15
|
|
|
|
16
|
|
|
use Administration\Domain\Supplier\Command\EditSupplier; |
17
|
|
|
use Administration\Infrastructure\Persistence\DoctrineOrm\Entities\Supplier as SupplierEntity; |
18
|
|
|
use Administration\Infrastructure\Persistence\DoctrineOrm\Repositories\DoctrineSupplierRepository; |
19
|
|
|
use Core\Domain\Protocol\Common\Command\CommandHandlerInterface; |
20
|
|
|
use Doctrine\ORM\NonUniqueResultException; |
|
|
|
|
21
|
|
|
use Doctrine\ORM\ORMException; |
|
|
|
|
22
|
|
|
|
23
|
|
|
class EditSupplierHandler implements CommandHandlerInterface |
24
|
|
|
{ |
25
|
|
|
private DoctrineSupplierRepository $repository; |
26
|
|
|
|
27
|
|
|
public function __construct(DoctrineSupplierRepository $repository) |
28
|
|
|
{ |
29
|
|
|
$this->repository = $repository; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @throws NonUniqueResultException |
34
|
|
|
* @throws ORMException |
35
|
|
|
*/ |
36
|
|
|
public function __invoke(EditSupplier $command): void |
37
|
|
|
{ |
38
|
|
|
$supplierToUpdate = $this->repository->findOneByUuid($command->uuid()->toString()); |
39
|
|
|
|
40
|
|
|
if (null === $supplierToUpdate) { |
41
|
|
|
throw new \DomainException('Supplier provided does not exist!'); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
$supplier = $this->updateSupplier($command, $supplierToUpdate); |
45
|
|
|
|
46
|
|
|
$this->repository->save($supplier); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
private function updateSupplier(EditSupplier $command, SupplierEntity $supplier): SupplierEntity |
50
|
|
|
{ |
51
|
|
|
$supplier->setCompanyName($command->name()->getValue()); |
52
|
|
|
$supplier->setAddress($command->address()); |
53
|
|
|
$supplier->setZipCode($command->zipCode()); |
54
|
|
|
$supplier->setTown($command->town()); |
55
|
|
|
$supplier->setCountry($command->country()); |
56
|
|
|
$supplier->setPhone($command->phone()->getValue()); |
57
|
|
|
$supplier->setFacsimile($command->facsimile()->getValue()); |
58
|
|
|
$supplier->setEmail($command->email()->getValue()); |
59
|
|
|
$supplier->setContactName($command->contactName()); |
60
|
|
|
$supplier->setCellphone($command->cellphone()->getValue()); |
61
|
|
|
$supplier->setFamilyLog($command->familyLog()->path()); |
62
|
|
|
$supplier->setDelayDelivery($command->delayDelivery()); |
63
|
|
|
$supplier->setOrderDays($command->orderDays()); |
64
|
|
|
|
65
|
|
|
return $supplier; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
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