regateEmail = new Address(Config::string('mail.to.regate')); } /** * @param \Domain\Events\Dto\OrderPlacedLine[] $lines * * @throws \Domain\Exceptions\OrderTunnel\RegateExportFailedException */ #[\Override] public function processOrder( OrderReference $reference, Matricule $employeeMatricule, CarbonImmutable $pickupDay, array $lines, ): void { $rows = []; foreach ($lines as $line) { $rows[] = [ (string) $line->productIncoId->value, $employeeMatricule->value, (string) $line->productIncoId->value, 'commande ferme', (string) $line->productOrderUnit->value, $line->productOrderUnit->toRegateCode(), '', $pickupDay->format('d/m/Y'), (string) $line->quantity, (string) $reference, ]; } $csvContent = $this->csvGenerator->generate($this->header, $rows); $now = CarbonImmutable::now(); $fileName = sprintf( 'BTQ-%s-%s%s.csv', $reference, $now->format('Ymd_His'), \microtime(true) ); try { $this->mailer->to($this->regateEmail) ->send(new RegateOrderMail($csvContent, $fileName)); } catch (\Throwable $e) { throw new RegateExportFailedException($e->getMessage(), $e); } } }