X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/d28abf24d404fe4eb281866e6d37d704602e87a0..refs/pull/2615/head:/app/Http/Controllers/ChapterExportController.php diff --git a/app/Http/Controllers/ChapterExportController.php b/app/Http/Controllers/ChapterExportController.php index de46baa12..52d087442 100644 --- a/app/Http/Controllers/ChapterExportController.php +++ b/app/Http/Controllers/ChapterExportController.php @@ -1,78 +1,57 @@ -entityRepo = $entityRepo; - $this->exportService = $exportService; - parent::__construct(); + $this->chapterRepo = $chapterRepo; + $this->exportFormatter = $exportFormatter; } /** - * Exports a chapter to pdf . - * @param string $bookSlug - * @param string $chapterSlug - * @return Response + * Exports a chapter to pdf. * @throws NotFoundException * @throws Throwable */ public function pdf(string $bookSlug, string $chapterSlug) { - $chapter = $this->entityRepo->getBySlug('chapter', $chapterSlug, $bookSlug); - $pdfContent = $this->exportService->chapterToPdf($chapter); + $chapter = $this->chapterRepo->getBySlug($bookSlug, $chapterSlug); + $pdfContent = $this->exportFormatter->chapterToPdf($chapter); return $this->downloadResponse($pdfContent, $chapterSlug . '.pdf'); } /** * Export a chapter to a self-contained HTML file. - * @param string $bookSlug - * @param string $chapterSlug - * @return Response * @throws NotFoundException * @throws Throwable */ public function html(string $bookSlug, string $chapterSlug) { - $chapter = $this->entityRepo->getBySlug('chapter', $chapterSlug, $bookSlug); - $containedHtml = $this->exportService->chapterToContainedHtml($chapter); + $chapter = $this->chapterRepo->getBySlug($bookSlug, $chapterSlug); + $containedHtml = $this->exportFormatter->chapterToContainedHtml($chapter); return $this->downloadResponse($containedHtml, $chapterSlug . '.html'); } /** * Export a chapter to a simple plaintext .txt file. - * @param string $bookSlug - * @param string $chapterSlug - * @return Response * @throws NotFoundException */ public function plainText(string $bookSlug, string $chapterSlug) { - $chapter = $this->entityRepo->getBySlug('chapter', $chapterSlug, $bookSlug); - $chapterText = $this->exportService->chapterToPlainText($chapter); + $chapter = $this->chapterRepo->getBySlug($bookSlug, $chapterSlug); + $chapterText = $this->exportFormatter->chapterToPlainText($chapter); return $this->downloadResponse($chapterText, $chapterSlug . '.txt'); } }