1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-27 06:01:54 +03:00

Extracted some methods into a BookRepo

This commit is contained in:
Dan Brown
2019-09-15 23:28:23 +01:00
parent d28abf24d4
commit 60d0f96cd7
14 changed files with 233 additions and 173 deletions

View File

@ -3,16 +3,16 @@
namespace BookStack\Http\Controllers;
use BookStack\Entities\ExportService;
use BookStack\Entities\Repos\EntityRepo;
use BookStack\Entities\Repos\BookRepo;
use BookStack\Exceptions\NotFoundException;
use Throwable;
class BookExportController extends Controller
{
/**
* @var EntityRepo
* @var BookRepo
*/
protected $entityRepo;
protected $bookRepo;
/**
* @var ExportService
@ -21,12 +21,12 @@ class BookExportController extends Controller
/**
* BookExportController constructor.
* @param EntityRepo $entityRepo
* @param BookRepo $bookRepo
* @param ExportService $exportService
*/
public function __construct(EntityRepo $entityRepo, ExportService $exportService)
public function __construct(BookRepo $bookRepo, ExportService $exportService)
{
$this->entityRepo = $entityRepo;
$this->bookRepo = $bookRepo;
$this->exportService = $exportService;
parent::__construct();
}
@ -40,7 +40,7 @@ class BookExportController extends Controller
*/
public function pdf(string $bookSlug)
{
$book = $this->entityRepo->getBySlug('book', $bookSlug);
$book = $this->bookRepo->getBySlug($bookSlug);
$pdfContent = $this->exportService->bookToPdf($book);
return $this->downloadResponse($pdfContent, $bookSlug . '.pdf');
}
@ -54,7 +54,7 @@ class BookExportController extends Controller
*/
public function html(string $bookSlug)
{
$book = $this->entityRepo->getBySlug('book', $bookSlug);
$book = $this->bookRepo->getBySlug($bookSlug);
$htmlContent = $this->exportService->bookToContainedHtml($book);
return $this->downloadResponse($htmlContent, $bookSlug . '.html');
}
@ -67,7 +67,7 @@ class BookExportController extends Controller
*/
public function plainText(string $bookSlug)
{
$book = $this->entityRepo->getBySlug('book', $bookSlug);
$book = $this->bookRepo->getBySlug($bookSlug);
$textContent = $this->exportService->bookToPlainText($book);
return $this->downloadResponse($textContent, $bookSlug . '.txt');
}