X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/60d0f96cd754a85c637a5f34dcc0341f4ef72a46..refs/pull/2416/head:/app/Http/Controllers/ChapterExportController.php diff --git a/app/Http/Controllers/ChapterExportController.php b/app/Http/Controllers/ChapterExportController.php index 15d67d539..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->getEntityBySlug('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->getEntityBySlug('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->getEntityBySlug('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'); } }