mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Refactor title translation logic in SavedExportController
Simplified and centralized title translation by introducing a check for TranslatableInterface. This ensures consistent handling of translatable titles and improves code readability.
This commit is contained in:
parent
aa44577484
commit
66c089e862
@ -36,6 +36,7 @@ use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Translation\TranslatableMessage;
|
||||
use Symfony\Contracts\Translation\TranslatableInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
final readonly class SavedExportController
|
||||
@ -100,15 +101,17 @@ final readonly class SavedExportController
|
||||
throw new AccessDeniedHttpException('only regular user can create a saved export');
|
||||
}
|
||||
|
||||
$export = $this->exportManager->getExport($exportGeneration->getExportAlias());
|
||||
$title = $export->getTitle() instanceof TranslatableInterface ? $export->getTitle()->trans($this->translator) :
|
||||
$this->translator->trans($export->getTitle());
|
||||
|
||||
$savedExport = new SavedExport();
|
||||
$savedExport
|
||||
->setExportAlias($exportGeneration->getExportAlias())
|
||||
->setUser($user)
|
||||
->setOptions($exportGeneration->getOptions())
|
||||
->setTitle(
|
||||
$request->query->has('title') ?
|
||||
$request->query->get('title') :
|
||||
$this->translator->trans($this->exportManager->getExport($exportGeneration->getExportAlias())->getTitle())
|
||||
$request->query->has('title') ? $request->query->get('title') : $title
|
||||
);
|
||||
|
||||
return $this->handleEdit($savedExport, $request);
|
||||
|
Loading…
x
Reference in New Issue
Block a user