fix tickets getting cut in order pdf
All checks were successful
build / build (pull_request) Successful in 47s
All checks were successful
build / build (pull_request) Successful in 47s
This commit is contained in:
@ -12,6 +12,7 @@ use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
||||
use Symfony\Component\Mailer\MailerInterface;
|
||||
use Symfony\Component\Mime\Address;
|
||||
use Symfony\Component\Mime\Part\DataPart;
|
||||
use Symfony\Component\VarDumper\Cloner\Data;
|
||||
use Twig\Environment;
|
||||
|
||||
class TicketEmailService
|
||||
@ -33,14 +34,25 @@ class TicketEmailService
|
||||
->to(new Address($payment->getCustomer()?->getEmail(), $payment->getCustomer()?->getFirstname() . ' ' . $payment->getCustomer()?->getLastname()))
|
||||
->context([
|
||||
'payment' => $payment,
|
||||
])
|
||||
->addPart(new DataPart($this->generateTicket($payment->getCustomer()?->getTickets()), 'tickets.pdf', 'application/pdf'));
|
||||
]);
|
||||
|
||||
$acc = 0;
|
||||
foreach ($this->generateTicket($payment->getCustomer()?->getTickets()) as $pdf) {
|
||||
$mail->attach($pdf, 'tickets-'.++$acc.'.pdf', 'application/pdf');
|
||||
}
|
||||
|
||||
$this->mailer->send($mail);
|
||||
}
|
||||
|
||||
private function generateTicket(Collection $tickets): string
|
||||
private function generateTicket(Collection $tickets): array
|
||||
{
|
||||
return (new DompdfWrapper(new DompdfFactory()))->getPdf($this->twig->render('email/pdf.html.twig', ['tickets' => $tickets]));
|
||||
$ticketChunks = array_chunk($tickets->toArray(), 3);
|
||||
|
||||
$pdfs = [];
|
||||
foreach ($ticketChunks as $ticket) {
|
||||
$pdfs[] = (new DompdfWrapper(new DompdfFactory()))->getPdf($this->twig->render('email/pdf.html.twig', ['tickets' => $ticket]));
|
||||
}
|
||||
|
||||
return $pdfs;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user