From cc769fd4baddef4e4fdaf9979ecfdde9d26cb010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 16 Feb 2026 13:30:07 +0100 Subject: [PATCH] Support translatable labels in `FilterOrderHelper` and `FilterOrderHelperBuilder` - Updated methods to accept `string|TranslatableInterface` for label parameters, allowing translation capabilities. - Added `Symfony\Contracts\Translation\TranslatableInterface` imports in both classes. --- .../Templating/Listing/FilterOrderHelper.php | 9 +++++---- .../Templating/Listing/FilterOrderHelperBuilder.php | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php index 48a25670d..993fd871d 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php @@ -16,6 +16,7 @@ use Chill\MainBundle\Form\Type\Listing\FilterOrderType; use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Contracts\Translation\TranslatableInterface; final class FilterOrderHelper { @@ -53,7 +54,7 @@ final class FilterOrderHelper private readonly RequestStack $requestStack, ) {} - public function addSingleCheckbox(string $name, string $label): self + public function addSingleCheckbox(string $name, string|TranslatableInterface $label): self { $this->singleCheckbox[$name] = ['label' => $label]; @@ -63,7 +64,7 @@ final class FilterOrderHelper /** * @param class-string $class */ - public function addEntityChoice(string $name, string $class, string $label, array $choices, array $options = []): self + public function addEntityChoice(string $name, string $class, string|TranslatableInterface $label, array $choices, array $options = []): self { $this->entityChoices[$name] = ['label' => $label, 'class' => $class, 'choices' => $choices, 'options' => $options]; @@ -75,7 +76,7 @@ final class FilterOrderHelper return $this->entityChoices; } - public function addUserPicker(string $name, ?string $label = null, array $options = []): self + public function addUserPicker(string $name, string|TranslatableInterface|null $label = null, array $options = []): self { $this->userPickers[$name] = ['label' => $label, 'options' => $options]; @@ -98,7 +99,7 @@ final class FilterOrderHelper return $this; } - public function addDateRange(string $name, ?string $label = null, ?\DateTimeImmutable $from = null, ?\DateTimeImmutable $to = null): self + public function addDateRange(string $name, string|TranslatableInterface|null $label = null, ?\DateTimeImmutable $from = null, ?\DateTimeImmutable $to = null): self { $this->dateRanges[$name] = ['from' => $from, 'to' => $to, 'label' => $label]; diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php index 350f71d4b..010b17217 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php @@ -13,6 +13,7 @@ namespace Chill\MainBundle\Templating\Listing; use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Contracts\Translation\TranslatableInterface; class FilterOrderHelperBuilder { @@ -39,7 +40,7 @@ class FilterOrderHelperBuilder public function __construct(private readonly FormFactoryInterface $formFactory, private readonly RequestStack $requestStack) {} - public function addSingleCheckbox(string $name, string $label): self + public function addSingleCheckbox(string $name, string|TranslatableInterface $label): self { $this->singleCheckboxes[$name] = ['label' => $label]; @@ -56,14 +57,14 @@ class FilterOrderHelperBuilder /** * @param class-string $class */ - public function addEntityChoice(string $name, string $label, string $class, array $choices, ?array $options = []): self + public function addEntityChoice(string $name, string|TranslatableInterface $label, string $class, array $choices, ?array $options = []): self { $this->entityChoices[$name] = ['label' => $label, 'class' => $class, 'choices' => $choices, 'options' => $options]; return $this; } - public function addDateRange(string $name, ?string $label = null, ?\DateTimeImmutable $from = null, ?\DateTimeImmutable $to = null): self + public function addDateRange(string $name, string|TranslatableInterface|null $label = null, ?\DateTimeImmutable $from = null, ?\DateTimeImmutable $to = null): self { $this->dateRanges[$name] = ['from' => $from, 'to' => $to, 'label' => $label]; @@ -77,7 +78,7 @@ class FilterOrderHelperBuilder return $this; } - public function addUserPicker(string $name, ?string $label = null, ?array $options = []): self + public function addUserPicker(string $name, string|TranslatableInterface|null $label = null, ?array $options = []): self { $this->userPickers[$name] = ['label' => $label, 'options' => $options];