- Refactor MangaScraperService (not used everywhere now)
- Added JavascriptScraper.php
- Added alternatives slugs in Manga.php
- Improvement in manga edit form
This commit is contained in:
Jérémy Guillot
2024-07-21 19:08:46 +02:00
parent ff59aa5d77
commit fafff5014c
21 changed files with 1180 additions and 28 deletions

View File

@@ -4,6 +4,7 @@ namespace App\Controller;
use App\Entity\Chapter;
use App\Entity\Manga;
use App\Form\MangaEditType;
use App\Manager\Toolbar\Factory\ToolbarFactory;
use App\Message\DownloadChapter;
use App\Message\RefreshMetadata;
@@ -79,9 +80,12 @@ class MangaController extends AbstractController
throw new NotFoundHttpException("Le manga demandé n'existe pas.");
}
$form = $this->createForm(MangaEditType::class, $manga);
return $this->render('manga/show_chapters.html.twig', [
'manga' => $manga,
'toolbar' => $this->toolbarFactory->createToolbar('chapter_list', ['mangaId' => $manga->getId(), 'isMonitored' => (int) $manga->isMonitored()])->getGroups(),
'form' => $form->createView(),
]);
}
@@ -101,6 +105,25 @@ class MangaController extends AbstractController
}
}
#[Route('/manga/{id}/edit', name: 'app_manga_edit', methods: ['POST'])]
public function edit(Request $request, Manga $manga, EntityManagerInterface $entityManager): JsonResponse|Response
{
$form = $this->createForm(MangaEditType::class, $manga);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$entityManager->flush();
return $this->redirectToRoute('app_manga_show', ['mangaSlug' => $manga->getSlug()]);
}
$errors = [];
foreach ($form->getErrors(true) as $error) {
$errors[] = $error->getMessage();
}
return new JsonResponse(['errors' => $errors], 400);
}
public function _chaptersByManga(int $id): Response
{