Added navbar and button to skip automatic search of book info online.
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Controller;
|
||||
use App\Entity\Book;
|
||||
use App\Entity\File;
|
||||
use App\Repository\FileRepository;
|
||||
use App\Service\FileService;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
@@ -27,27 +28,16 @@ class FileController extends AbstractController
|
||||
Request $request,
|
||||
FileRepository $fileRepository,
|
||||
File $file,
|
||||
Filesystem $filesystem
|
||||
FileService $fileService
|
||||
): Response {
|
||||
$filePath = $this->getParameter('book_files') . '/' . 'ebook_' . $file->getBook()->getId() . '_' .
|
||||
md5($file->getFileName()) . '.' .
|
||||
$file->getExtension();
|
||||
$filesystem->remove($filePath);
|
||||
|
||||
if (!$filesystem->exists($filePath)) {
|
||||
$fileRepository->remove($file, 'true');
|
||||
}
|
||||
$fileService->removeFiles($file);
|
||||
$fileRepository->remove($file, 'true');
|
||||
return $this->redirect($request->headers->get('referer'));
|
||||
}
|
||||
|
||||
#[Route('/file/{id}', name: 'app_file_download', methods: ['GET'])]
|
||||
public function get(File $file)
|
||||
public function get(File $file, FileService $fileService)
|
||||
{
|
||||
return $this->file(
|
||||
$this->getParameter('book_files') . '/' . 'ebook_' . $file->getBook()->getId() . '_' .
|
||||
md5($file->getFileName()) . '.' .
|
||||
$file->getExtension(),
|
||||
$file->getFileName()
|
||||
);
|
||||
return $this->file($fileService->getFilePath($file), $file->getFileName());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user