X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/60d0f96cd754a85c637a5f34dcc0341f4ef72a46..refs/pull/2023/head:/app/Http/Controllers/ChapterExportController.php diff --git a/app/Http/Controllers/ChapterExportController.php b/app/Http/Controllers/ChapterExportController.php index 15d67d539..0c86f8548 100644 --- a/app/Http/Controllers/ChapterExportController.php +++ b/app/Http/Controllers/ChapterExportController.php @@ -1,77 +1,57 @@ -entityRepo = $entityRepo; + $this->chapterRepo = $chapterRepo; $this->exportService = $exportService; parent::__construct(); } /** - * 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); + $chapter = $this->chapterRepo->getBySlug($bookSlug, $chapterSlug); $pdfContent = $this->exportService->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); + $chapter = $this->chapterRepo->getBySlug($bookSlug, $chapterSlug); $containedHtml = $this->exportService->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); + $chapter = $this->chapterRepo->getBySlug($bookSlug, $chapterSlug); $chapterText = $this->exportService->chapterToPlainText($chapter); return $this->downloadResponse($chapterText, $chapterSlug . '.txt'); }