4a77449a41
| Numéro du ticket | Titre du ticket | |------------------|-----------------| | #203 | Réceptions — Parcours de pesée multi-étapes | ## Description de la PR [#203] Réceptions — Parcours de pesée multi-étapes ## Modification du .env ## Check list - [x] Pas de régression - [x] TU/TI/TF rédigée - [x] TU/TI/TF OK - [x] CHANGELOG modifié Reviewed-on: https://gitea.malio.fr/MALIO-DEV/Ferme/pulls/3 Reviewed-by: THOLOT DECHENE Matthieu <matthieu@yuno.malio.fr> Co-authored-by: AUTIN Tristan <tristan@yuno.malio.fr> Co-committed-by: AUTIN Tristan <tristan@yuno.malio.fr>
31 lines
847 B
PHP
31 lines
847 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\State;
|
|
|
|
use ApiPlatform\Metadata\Operation;
|
|
use ApiPlatform\State\ProviderInterface;
|
|
use App\Dto\PontBasculeReading;
|
|
use App\Exception\PontBasculeException;
|
|
use App\Service\PontBasculeService;
|
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
|
|
|
final readonly class ReceptionWeighingProvider implements ProviderInterface
|
|
{
|
|
public function __construct(
|
|
private PontBasculeService $pontBasculeService,
|
|
) {}
|
|
|
|
public function provide(Operation $operation, array $uriVariables = [], array $context = []): ?PontBasculeReading
|
|
{
|
|
try {
|
|
$result = $this->pontBasculeService->fetch();
|
|
} catch (PontBasculeException $exception) {
|
|
throw new HttpException(500, $exception->getMessage(), $exception);
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
}
|