All checks were successful
Auto Tag Develop / tag (push) Successful in 6s
- 3 nouveaux endpoints API Platform pass-through sur /api/bovins/{inventory|returned-dossiers|presumed-exits} consommant BovinApiInterface v0.0.6
- AnimalSummaryMapper (src/Service/) factorisant le mapping DTO EDNOTIF -> ressource
- src/State/ réorganisé par domaine (Bovin/, Reception/, Shipment/, Building/, User/, System/)
- tag OpenAPI "Bovins" pour regrouper les endpoints ednotif dans Swagger
- malio/ednotif-bundle passé à v0.0.6
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
| Numéro du ticket | Titre du ticket |
|------------------|-----------------|
| | |
## Description de la PR
## Modification du .env
## Check list
- [ ] Pas de régression
- [ ] TU/TI/TF rédigée
- [ ] TU/TI/TF OK
- [ ] CHANGELOG modifié
Reviewed-on: #47
Co-authored-by: tristan <tristan@yuno.malio.fr>
Co-committed-by: tristan <tristan@yuno.malio.fr>
51 lines
1.4 KiB
PHP
51 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\State\Bovin;
|
|
|
|
use ApiPlatform\Metadata\Operation;
|
|
use ApiPlatform\State\ProviderInterface;
|
|
use App\ApiResource\BovinReturnedDossiers;
|
|
use App\Service\AnimalSummaryMapper;
|
|
use DateTimeImmutable;
|
|
use Exception;
|
|
use Malio\EdnotifBundle\Bovin\Api\BovinApiInterface;
|
|
|
|
/**
|
|
* @implements ProviderInterface<null|BovinReturnedDossiers>
|
|
*/
|
|
final class BovinReturnedDossiersProvider implements ProviderInterface
|
|
{
|
|
public function __construct(
|
|
private BovinApiInterface $bovinApi,
|
|
private AnimalSummaryMapper $animalSummaryMapper,
|
|
) {}
|
|
|
|
public function provide(Operation $operation, array $uriVariables = [], array $context = []): ?BovinReturnedDossiers
|
|
{
|
|
$startDateRaw = (string) ($uriVariables['startDate'] ?? '');
|
|
if ('' === $startDateRaw) {
|
|
return null;
|
|
}
|
|
|
|
try {
|
|
$startDate = new DateTimeImmutable($startDateRaw);
|
|
} catch (Exception) {
|
|
return null;
|
|
}
|
|
|
|
$dto = $this->bovinApi->getReturnedDossiers($startDate);
|
|
|
|
$resource = new BovinReturnedDossiers();
|
|
$resource->startDate = $dto->startDate?->format('Y-m-d') ?? $startDate->format('Y-m-d');
|
|
$resource->nbBovins = $dto->nbBovins;
|
|
|
|
foreach ($dto->animals as $animalDto) {
|
|
$resource->animals[] = $this->animalSummaryMapper->map($animalDto);
|
|
}
|
|
|
|
return $resource;
|
|
}
|
|
}
|