twig = $twig; } public function supports(InvoiceDocument $document): bool { return stripos($document->getFilename(), '.txt.twig') !== false; } public function render(InvoiceDocument $document, InvoiceModel $model): Response { $content = $this->twig->render('@invoice/' . basename($document->getFilename()), [ 'model' => $model ]); $filename = (string) new InvoiceFilename($model); $response = new Response($content); $disposition = $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $filename . '.txt'); $response->headers->set('Content-Type', 'text/plain'); $response->headers->set('Content-Disposition', $disposition); return $response; } }