From 49f4cce72a048ab670e6b06801a13668fa5c3f01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 11 Mar 2025 15:09:26 +0100 Subject: [PATCH] fixup! Rename `getVersion` to `getNormalizationVersion`. --- .../Fixture/add-method-chained-field.php.inc | 120 ++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 utils/rector/tests/ChillBundleAddNormalizationMethodsOnExportRector/Fixture/add-method-chained-field.php.inc diff --git a/utils/rector/tests/ChillBundleAddNormalizationMethodsOnExportRector/Fixture/add-method-chained-field.php.inc b/utils/rector/tests/ChillBundleAddNormalizationMethodsOnExportRector/Fixture/add-method-chained-field.php.inc new file mode 100644 index 000000000..036a53b8a --- /dev/null +++ b/utils/rector/tests/ChillBundleAddNormalizationMethodsOnExportRector/Fixture/add-method-chained-field.php.inc @@ -0,0 +1,120 @@ +add('field', ChoiceType::class, [ + 'choices' => ['one', 'two', 'three', 'four', 'five'], + 'multiple' => false, + ]) + ->add('entity', EntityType::class, []) + ->add('user', \Chill\MainBundle\Form\Type\PickUserDynamicType::class, []) + ->add('rolling_date', \Chill\MainBundle\Form\Type\PickRollingDateType::class) + ->add('date', \Chill\MainBundle\Form\Type\ChillDateType::class, []); + } + + public function getFormDefaultData(): array + { + return []; + } + + public function describeAction($data, $format = 'string') + { + return []; + } + + public function addRole(): ?string + { + return null; + } + + public function alterQuery(\Doctrine\ORM\QueryBuilder $qb, $data, \Chill\MainBundle\Export\ExportGenerationContext $exportGenerationContext) + { + // nothing to add here + } + + public function applyOn() + { + return ['something']; + } +} + +?> +----- +add('field', ChoiceType::class, [ + 'choices' => ['one', 'two', 'three', 'four', 'five'], + 'multiple' => false, + ]) + ->add('entity', EntityType::class, []) + ->add('user', \Chill\MainBundle\Form\Type\PickUserDynamicType::class, []) + ->add('rolling_date', \Chill\MainBundle\Form\Type\PickRollingDateType::class) + ->add('date', \Chill\MainBundle\Form\Type\ChillDateType::class, []); + } + public function getNormalizationVersion(): int + { + return 1; + } + public function normalizeFormData(array $formData): array + { + return ['field' => $formData['field'], 'entity' => $this->normalizeDoctrineEntity($formData['entity']), 'user' => $this->normalizeDoctrineEntity($formData['user']), 'rolling_date' => $formData['rolling_date']->normalize(), 'date' => $this->normalizeDate($formData['date'])]; + } + public function denormalizeFormData(array $formData, int $fromVersion): array + { + return ['field' => $formData['field'], 'entity' => $this->denormalizeDoctrineEntity($formData['entity'], $this->someRepository), 'user' => $this->denormalizeDoctrineEntity($formData['user'], $this->someRepository), 'rolling_date' => \Chill\MainBundle\Service\RollingDate\RollingDate::fromNormalized($formData['rolling_date']), 'date' => $this->denormalizeDate($formData['date'])]; + } + + public function getFormDefaultData(): array + { + return []; + } + + public function describeAction($data, $format = 'string') + { + return []; + } + + public function addRole(): ?string + { + return null; + } + + public function alterQuery(\Doctrine\ORM\QueryBuilder $qb, $data, \Chill\MainBundle\Export\ExportGenerationContext $exportGenerationContext) + { + // nothing to add here + } + + public function applyOn() + { + return ['something']; + } +} + +?>