Refactor export-related controllers and helpers

Removed unused dependencies, obsolete methods, and redundant parameters across ExportController, ExportFormHelper, and SavedExportController. Simplified session handling and aligned method signatures to improve maintainability and code readability.
This commit is contained in:
2025-04-01 14:19:15 +02:00
parent 80d8f967fa
commit 68b61b7d8a
5 changed files with 22 additions and 249 deletions

View File

@@ -27,7 +27,7 @@ use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
@@ -43,7 +43,6 @@ final readonly class SavedExportController
private FormFactoryInterface $formFactory,
private SavedExportRepositoryInterface $savedExportRepository,
private Security $security,
private SessionInterface $session,
private TranslatorInterface $translator,
private UrlGeneratorInterface $urlGenerator,
) {}
@@ -63,7 +62,10 @@ final readonly class SavedExportController
$this->entityManager->remove($savedExport);
$this->entityManager->flush();
$this->session->getFlashBag()->add('success', $this->translator->trans('saved_export.Export is deleted'));
$session = $request->getSession();
if ($session instanceof Session) {
$session->getFlashBag()->add('success', $this->translator->trans('saved_export.Export is deleted'));
}
return new RedirectResponse(
$this->urlGenerator->generate('chill_main_export_saved_list_my')
@@ -108,7 +110,9 @@ final readonly class SavedExportController
$exportGeneration->setSavedExport($savedExport);
$this->entityManager->flush();
$this->session->getFlashBag()->add('success', $this->translator->trans('saved_export.Saved export is saved!'));
if (($session = $request->getSession()) instanceof Session) {
$session->getFlashBag()->add('success', $this->translator->trans('saved_export.Saved export is saved!'));
}
return new RedirectResponse(
$this->urlGenerator->generate('chill_main_export_saved_list_my'),
@@ -139,10 +143,12 @@ final readonly class SavedExportController
if ($form->isSubmitted() && $form->isValid()) {
$this->entityManager->flush();
$this->session->getFlashBag()->add('success', $this->translator->trans('saved_export.Saved export is saved!'));
if (($session = $request->getSession()) instanceof Session) {
$session->getFlashBag()->add('success', $this->translator->trans('saved_export.Saved export is saved!'));
}
return new RedirectResponse(
$this->urlGenerator->generate('chill_main_export_saved_list_my')
$this->urlGenerator->generate('chill_main_export_saved_list_my'),
);
}