feat: ajout des 3 derniers WS en lecture du bundle malio ednotif (!47)
All checks were successful
Auto Tag Develop / tag (push) Successful in 6s
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>
This commit was merged in pull request #47.
This commit is contained in:
63
src/State/Reception/ReceptionReceiptProvider.php
Normal file
63
src/State/Reception/ReceptionReceiptProvider.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\State\Reception;
|
||||
|
||||
use ApiPlatform\Metadata\Operation;
|
||||
use ApiPlatform\State\ProviderInterface;
|
||||
use App\Entity\Reception;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Dompdf\Dompdf;
|
||||
use Dompdf\Options;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Twig\Environment;
|
||||
use Twig\Error\LoaderError;
|
||||
use Twig\Error\RuntimeError;
|
||||
use Twig\Error\SyntaxError;
|
||||
|
||||
final readonly class ReceptionReceiptProvider implements ProviderInterface
|
||||
{
|
||||
public function __construct(
|
||||
private Environment $twig,
|
||||
private EntityManagerInterface $entityManager,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @throws RuntimeError
|
||||
* @throws SyntaxError
|
||||
* @throws LoaderError
|
||||
*/
|
||||
public function provide(Operation $operation, array $uriVariables = [], array $context = []): Response
|
||||
{
|
||||
$id = $uriVariables['id'] ?? null;
|
||||
if (null === $id) {
|
||||
throw new NotFoundHttpException('Reception not found.');
|
||||
}
|
||||
|
||||
$reception = $this->entityManager->getRepository(Reception::class)->find($id);
|
||||
if (!$reception instanceof Reception) {
|
||||
throw new NotFoundHttpException('Reception not found.');
|
||||
}
|
||||
|
||||
$options = new Options();
|
||||
$options->set('isRemoteEnabled', true);
|
||||
|
||||
$dompdf = new Dompdf($options);
|
||||
$html = $this->twig->render('reception_voucher.html.twig', [
|
||||
'reception' => $reception,
|
||||
]);
|
||||
|
||||
$dompdf->loadHtml($html);
|
||||
$dompdf->setPaper('A4');
|
||||
$dompdf->render();
|
||||
|
||||
$filename = sprintf('bon-reception-%d.pdf', $reception->getId());
|
||||
|
||||
return new Response($dompdf->output(), Response::HTTP_OK, [
|
||||
'Content-Type' => 'application/pdf',
|
||||
'Content-Disposition' => 'inline; filename="'.$filename.'"',
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user