class ChapterExportApiController extends ApiController
{
- protected $chapterRepo;
- protected $exportService;
+ protected $exportFormatter;
/**
* ChapterExportController constructor.
*/
- public function __construct(BookRepo $chapterRepo, ExportFormatter $exportService)
+ public function __construct(ExportFormatter $exportFormatter)
{
- $this->chapterRepo = $chapterRepo;
- $this->exportService = $exportService;
+ $this->exportFormatter = $exportFormatter;
}
/**
public function exportPdf(int $id)
{
$chapter = Chapter::visible()->findOrFail($id);
- $pdfContent = $this->exportService->chapterToPdf($chapter);
+ $pdfContent = $this->exportFormatter->chapterToPdf($chapter);
return $this->downloadResponse($pdfContent, $chapter->slug . '.pdf');
}
public function exportHtml(int $id)
{
$chapter = Chapter::visible()->findOrFail($id);
- $htmlContent = $this->exportService->chapterToContainedHtml($chapter);
+ $htmlContent = $this->exportFormatter->chapterToContainedHtml($chapter);
return $this->downloadResponse($htmlContent, $chapter->slug . '.html');
}
public function exportPlainText(int $id)
{
$chapter = Chapter::visible()->findOrFail($id);
- $textContent = $this->exportService->chapterToPlainText($chapter);
+ $textContent = $this->exportFormatter->chapterToPlainText($chapter);
return $this->downloadResponse($textContent, $chapter->slug . '.txt');
}
}