Added:
- FileSystemManager.php refactoring of all write/read actions on filesystem Deleted: - old ToolbarManager.php
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Controller;
|
||||
use App\Entity\Chapter;
|
||||
use App\Entity\Manga;
|
||||
use App\Form\MangaEditType;
|
||||
use App\Manager\FileSystemManager;
|
||||
use App\Manager\Toolbar\Factory\ToolbarFactory;
|
||||
use App\Message\DownloadChapter;
|
||||
use App\Message\RefreshMetadata;
|
||||
@@ -38,7 +39,7 @@ class MangaController extends AbstractController
|
||||
private ImageManager $imageManager;
|
||||
|
||||
public function __construct(
|
||||
private readonly string $projectDir,
|
||||
private readonly FileSystemManager $fileSystemManager,
|
||||
private readonly MangaRepository $mangaRepository,
|
||||
private readonly ChapterRepository $chapterRepository,
|
||||
private readonly MessageBusInterface $bus,
|
||||
@@ -47,7 +48,6 @@ class MangaController extends AbstractController
|
||||
private readonly MangadexProvider $mangadexProvider,
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly NotificationService $notificationService,
|
||||
private readonly SluggerInterface $slugger,
|
||||
private readonly ContentSourceRepository $contentSourceRepository
|
||||
)
|
||||
{
|
||||
@@ -213,39 +213,6 @@ class MangaController extends AbstractController
|
||||
return new JsonResponse(['success' => 'Chapter hidden.'], 200);
|
||||
}
|
||||
|
||||
// #[Route('/manga/read/{mangaSlug}/{chapterNumber}/{pageNumber}', name: 'app_manga_read')]
|
||||
// public function readChapterPage(string $mangaSlug, float $chapterNumber, int $pageNumber = 1): Response
|
||||
// {
|
||||
// $manga = $this->mangaRepository->findOneBy(['slug' => $mangaSlug]);
|
||||
// if (!$manga) {
|
||||
// throw $this->createNotFoundException("Le manga demandé n'existe pas.");
|
||||
// }
|
||||
//
|
||||
// $chapter = $manga->getChapterByNumber($chapterNumber);
|
||||
// if (!$chapter) {
|
||||
// throw $this->createNotFoundException("Le chapitre demandé n'existe pas.");
|
||||
// }
|
||||
//
|
||||
// if (is_null($chapter->getCbzPath())) {
|
||||
// throw $this->createNotFoundException("Le chapitre demandé n'a pas été scrapé.");
|
||||
// }
|
||||
//
|
||||
// $pageContent = $this->cbzService->getPageContent($chapter->getCbzPath(), $pageNumber);
|
||||
// if (!$pageContent) {
|
||||
// throw $this->createNotFoundException("La page demandée n'existe pas.");
|
||||
// }
|
||||
//
|
||||
// $totalPages = $this->cbzService->getPageCount($chapter->getCbzPath());
|
||||
//
|
||||
// return $this->render('manga/manga_reader.html.twig', [
|
||||
// 'manga' => $manga,
|
||||
// 'chapter' => $chapter,
|
||||
// 'currentPage' => $pageNumber,
|
||||
// 'totalPages' => $totalPages,
|
||||
// 'pageContent' => base64_encode($pageContent),
|
||||
// ]);
|
||||
// }
|
||||
|
||||
#[Route('/manga/search/{query}', name: 'app_manga_search')]
|
||||
public function search(string $query = ''): Response
|
||||
{
|
||||
@@ -273,8 +240,7 @@ class MangaController extends AbstractController
|
||||
->setPublicationYear($request->request->get('publicationYear'))
|
||||
->setRating($request->request->get('rating'))
|
||||
->setExternalId($request->request->get('externalId'))
|
||||
->setMonitored(false)
|
||||
;
|
||||
->setMonitored(false);
|
||||
|
||||
// Traitement de l'image
|
||||
$imageUrl = $request->request->get('imageUrl');
|
||||
@@ -322,25 +288,24 @@ class MangaController extends AbstractController
|
||||
|
||||
// Générer un nom de fichier unique
|
||||
$originalFilename = pathinfo($imageUrl, PATHINFO_FILENAME);
|
||||
$safeFilename = $this->slugger->slug($originalFilename);
|
||||
$newFilename = $safeFilename . '-' . uniqid() . '.' . 'jpg';
|
||||
$newFilename = $this->fileSystemManager->generateUniqueImageFilename($imageUrl);
|
||||
|
||||
try {
|
||||
// Créer et sauvegarder la miniature
|
||||
$thumbnail = $this->imageManager->read($tempImagePath);
|
||||
$thumbnail->cover(300, 440);
|
||||
$thumbnail->save($this->projectDir . '/public/images/thumbnails/' . $newFilename, quality: 85);
|
||||
$thumbnail->save($this->fileSystemManager->getImagePath('thumbnails') . '/' . $newFilename, quality: 85);
|
||||
|
||||
// Sauvegarder l'image en taille réelle
|
||||
$fullImage = $this->imageManager->read($tempImagePath);
|
||||
$fullImage->save($this->projectDir . '/public/images/full/' . $newFilename, quality: 90);
|
||||
$fullImage->save($this->fileSystemManager->getImagePath('full') . '/' . $newFilename, quality: 90);
|
||||
|
||||
// Fermer et supprimer le fichier temporaire
|
||||
fclose($tempImage);
|
||||
|
||||
return [
|
||||
'full' => '/images/full/' . $newFilename,
|
||||
'thumbnail' => '/images/thumbnails/' . $newFilename
|
||||
'full' => $this->fileSystemManager->getImagePath('full') . '/' . $newFilename,
|
||||
'thumbnail' => $this->fileSystemManager->getImagePath('thumbnails') . '/' . $newFilename
|
||||
];
|
||||
|
||||
} catch (FileException $e) {
|
||||
|
||||
Reference in New Issue
Block a user