From 3c60c57985e3ea2fe3afb6fc1d8adaae939a962d Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 6 Aug 2025 07:48:48 +0200 Subject: [PATCH] Adapt export list events to new export features --- .../Export/Export/ListEvents.php | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillEventBundle/Export/Export/ListEvents.php b/src/Bundle/ChillEventBundle/Export/Export/ListEvents.php index dced123eb..7065e87c7 100644 --- a/src/Bundle/ChillEventBundle/Export/Export/ListEvents.php +++ b/src/Bundle/ChillEventBundle/Export/Export/ListEvents.php @@ -18,18 +18,22 @@ use Chill\EventBundle\Repository\EventBudgetElementRepository; use Chill\EventBundle\Repository\EventThemeRepository; use Chill\EventBundle\Security\EventVoter; use Chill\EventBundle\Templating\Entity\EventThemeRender; +use Chill\MainBundle\Export\ExportGenerationContext; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; use Chill\MainBundle\Export\ListInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\ThirdPartyBundle\Export\Helper\LabelThirdPartyHelper; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\NativeQuery; use Doctrine\ORM\Query; +use Doctrine\ORM\QueryBuilder; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Validator\Constraints\Callback; use Symfony\Component\Validator\Context\ExecutionContextInterface; +use Symfony\Contracts\Translation\TranslatableInterface; /** * Render a list of events. @@ -65,7 +69,7 @@ class ListEvents implements ListInterface, GroupedExportInterface $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center']; } - public function buildForm(FormBuilderInterface $builder) + public function buildForm(FormBuilderInterface $builder): void { $builder ->add('fields', ChoiceType::class, [ @@ -203,27 +207,27 @@ class ListEvents implements ListInterface, GroupedExportInterface }; } - public function getQueryKeys($data) + public function getQueryKeys(array $data): array { return $data['fields']; } - public function getResult($query, $data) + public function getResult($query, $data, ExportGenerationContext $context): array { return $query->getQuery()->getResult(Query::HYDRATE_SCALAR); } - public function getTitle() + public function getTitle(): string|TranslatableInterface { return 'export.event.list.title'; } - public function getType() + public function getType(): string { return Declarations::EVENT; } - public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) + public function initiateQuery(array $requiredModifiers, array $acl, array $data, ExportGenerationContext $context): NativeQuery|QueryBuilder { $centers = array_map(static fn ($el) => $el['center'], $acl); @@ -355,4 +359,19 @@ class ListEvents implements ListInterface, GroupedExportInterface return false; } + + public function normalizeFormData(array $formData): array + { + return ['fields' => $formData['fields']]; + } + + public function denormalizeFormData(array $formData, int $fromVersion): array + { + return ['fields' => $formData['fields']]; + } + + public function getNormalizationVersion(): int + { + return 1; + } }