+ return Response::create(
+ $pdf->Output('', 'S'),
+ 200,
+ [
+ 'Content-Description' => 'File Transfer',
+ 'Content-type' => 'application/pdf',
+ 'Content-Disposition' => 'attachment; filename="' . $this->title . '.pdf"',
+ 'Content-Transfer-Encoding' => 'binary',
+ ]
+ );
+ }
+
+ /**
+ * Inspired from CsvFileDumper.
+ *
+ * @return Response
+ */
+ private function produceCsv()
+ {
+ $delimiter = ';';
+ $enclosure = '"';
+ $handle = fopen('php://memory', 'rb+');
+
+ fputcsv($handle, ['Title', 'URL', 'Content', 'Tags', 'MIME Type', 'Language', 'Creation date'], $delimiter, $enclosure);
+
+ foreach ($this->entries as $entry) {
+ fputcsv(
+ $handle,
+ [
+ $entry->getTitle(),
+ $entry->getURL(),
+ // remove new line to avoid crazy results
+ str_replace(["\r\n", "\r", "\n"], '', $entry->getContent()),
+ implode(', ', $entry->getTags()->toArray()),
+ $entry->getMimetype(),
+ $entry->getLanguage(),
+ $entry->getCreatedAt()->format('d/m/Y h:i:s'),
+ ],
+ $delimiter,
+ $enclosure
+ );
+ }
+
+ rewind($handle);
+ $output = stream_get_contents($handle);
+ fclose($handle);
+
+ return Response::create(
+ $output,
+ 200,
+ [
+ 'Content-type' => 'application/csv',
+ 'Content-Disposition' => 'attachment; filename="' . $this->title . '.csv"',
+ 'Content-Transfer-Encoding' => 'UTF-8',
+ ]
+ );