Added:
- toolbar and fixes
This commit is contained in:
16
src/Twig/Components/DropdownMenu.php
Normal file
16
src/Twig/Components/DropdownMenu.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Twig\Components;
|
||||
|
||||
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
|
||||
use Symfony\UX\LiveComponent\Attribute\LiveProp;
|
||||
use Symfony\UX\LiveComponent\DefaultActionTrait;
|
||||
|
||||
#[AsLiveComponent]
|
||||
class DropdownMenu
|
||||
{
|
||||
use DefaultActionTrait;
|
||||
|
||||
#[LiveProp (writable: true)]
|
||||
public ?array $items = null;
|
||||
}
|
||||
@@ -8,6 +8,7 @@ use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
|
||||
use Symfony\UX\LiveComponent\Attribute\LiveAction;
|
||||
use Symfony\UX\LiveComponent\Attribute\LiveProp;
|
||||
@@ -27,6 +28,11 @@ class NewMangaForm
|
||||
#[LiveProp(writable: true)]
|
||||
public ?int $index = 0;
|
||||
|
||||
public function __construct(private UrlGeneratorInterface $urlGenerator)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function mount(Manga $manga): void
|
||||
{
|
||||
$this->manga = $manga;
|
||||
@@ -84,6 +90,8 @@ class NewMangaForm
|
||||
$manga->addChapter($chapter);
|
||||
}
|
||||
|
||||
$mangaChapterUrl = $this->urlGenerator->generate('app_manga_show', ['mangaSlug' => $manga->getSlug()]);
|
||||
|
||||
try {
|
||||
foreach ($manga->getChapters() as $chapter) {
|
||||
$entityManager->persist($chapter);
|
||||
@@ -93,11 +101,11 @@ class NewMangaForm
|
||||
$entityManager->flush();
|
||||
} catch (\Exception $e) {
|
||||
if ($e instanceof UniqueConstraintViolationException) {
|
||||
return new RedirectResponse('/manga/' . $manga->getSlug());
|
||||
return new RedirectResponse($mangaChapterUrl);
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return new RedirectResponse('/manga/' . $manga->getSlug());
|
||||
return new RedirectResponse($mangaChapterUrl);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user