From 6f3158f30f33264488887f5a0c8e271cb7d17747 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Thu, 7 Mar 2024 21:51:47 +0100 Subject: [PATCH] Shorten air bundle alias Match parent prototypes Cleanup --- Form/ApplicationType.php | 26 ++++++++++---------------- Form/ContactType.php | 4 ++-- Form/ImageType.php | 2 +- Form/LocationType.php | 7 ++++--- Form/RegisterType.php | 2 +- Form/SessionType.php | 11 ++++------- Form/SnippetType.php | 2 +- 7 files changed, 23 insertions(+), 31 deletions(-) diff --git a/Form/ApplicationType.php b/Form/ApplicationType.php index cee09db..f52ad8c 100644 --- a/Form/ApplicationType.php +++ b/Form/ApplicationType.php @@ -32,39 +32,33 @@ class ApplicationType extends AbstractType { /** * {@inheritdoc} */ - public function buildForm(FormBuilderInterface $builder, array $options) { - //Create form - $form = $builder; - + public function buildForm(FormBuilderInterface $builder, array $options): void { //Add dance field - $form->add('dance', EntityType::class, ['class' => 'Rapsys\AirBundle\Entity\Dance', 'choices' => $options['dance_choices'], 'preferred_choices' => $options['dance_favorites'], 'attr' => ['placeholder' => 'Your dance'], 'choice_translation_domain' => true, 'constraints' => [new NotBlank(['message' => 'Please provide your dance'])], 'data' => $options['dance_default']]); + $builder->add('dance', EntityType::class, ['class' => 'Rapsys\AirBundle\Entity\Dance', 'choices' => $options['dance_choices'], 'preferred_choices' => $options['dance_favorites'], 'attr' => ['placeholder' => 'Your dance'], 'choice_translation_domain' => true, 'constraints' => [new NotBlank(['message' => 'Please provide your dance'])], 'data' => $options['dance_default']]); //Add date field - $form->add('date', DateType::class, ['attr' => ['placeholder' => 'Your date', 'class' => 'date'], 'html5' => true, 'input' => 'datetime', 'widget' => 'single_text', 'format' => 'yyyy-MM-dd', 'data' => new \DateTime('+7 day'), 'constraints' => [new NotBlank(['message' => 'Please provide your date']), new Type(['type' => \DateTime::class, 'message' => 'Your date doesn\'t seems to be valid'])]]); + $builder->add('date', DateType::class, ['attr' => ['placeholder' => 'Your date', 'class' => 'date'], 'html5' => true, 'input' => 'datetime', 'widget' => 'single_text', 'format' => 'yyyy-MM-dd', 'data' => new \DateTime('+7 day'), 'constraints' => [new NotBlank(['message' => 'Please provide your date']), new Type(['type' => \DateTime::class, 'message' => 'Your date doesn\'t seems to be valid'])]]); //Add location field - $form->add('location', EntityType::class, ['class' => 'Rapsys\AirBundle\Entity\Location', 'choices' => $options['location_choices'], 'preferred_choices' => $options['location_favorites'], 'attr' => ['placeholder' => 'Your location'], 'choice_translation_domain' => true, 'constraints' => [new NotBlank(['message' => 'Please provide your location'])], 'data' => $options['location_default']]); + $builder->add('location', EntityType::class, ['class' => 'Rapsys\AirBundle\Entity\Location', 'choices' => $options['location_choices'], 'preferred_choices' => $options['location_favorites'], 'attr' => ['placeholder' => 'Your location'], 'choice_translation_domain' => true, 'constraints' => [new NotBlank(['message' => 'Please provide your location'])], 'data' => $options['location_default']]); //Add slot field - $form->add('slot', EntityType::class, ['class' => 'Rapsys\AirBundle\Entity\Slot', 'attr' => ['placeholder' => 'Your slot'], 'constraints' => [new NotBlank(['message' => 'Please provide your slot'])], 'choice_translation_domain' => true, 'data' => $options['slot_default']]); + $builder->add('slot', EntityType::class, ['class' => 'Rapsys\AirBundle\Entity\Slot', 'attr' => ['placeholder' => 'Your slot'], 'constraints' => [new NotBlank(['message' => 'Please provide your slot'])], 'choice_translation_domain' => true, 'data' => $options['slot_default']]); //Add extra user field if (!empty($options['user'])) { //XXX: choicetype used here to use our own custom translated string - $form->add('user', ChoiceType::class, ['attr' => ['placeholder' => 'Your user'], 'choice_translation_domain' => false, 'constraints' => [new NotBlank(['message' => 'Please provide your user'])], 'choices' => $options['user_choices'], 'data' => $options['user_default']]); + $builder->add('user', ChoiceType::class, ['attr' => ['placeholder' => 'Your user'], 'choice_translation_domain' => false, 'constraints' => [new NotBlank(['message' => 'Please provide your user'])], 'choices' => $options['user_choices'], 'data' => $options['user_default']]); } //Add submit - $form->add('submit', SubmitType::class, ['label' => 'Send', 'attr' => ['class' => 'submit']]); - - //Return form - return $form; + $builder->add('submit', SubmitType::class, ['label' => 'Send', 'attr' => ['class' => 'submit']]); } /** * {@inheritdoc} */ - public function configureOptions(OptionsResolver $resolver) { + public function configureOptions(OptionsResolver $resolver): void { //Set defaults $resolver->setDefaults(['error_bubbling' => true, 'dance_choices' => [], 'dance_default' => null, 'dance_favorites' => [], 'location_choices' => [], 'location_default' => null, 'location_favorites' => [], 'slot_default' => null, 'user' => true, 'user_choices' => [], 'user_default' => 1]); @@ -102,7 +96,7 @@ class ApplicationType extends AbstractType { /** * {@inheritdoc} */ - public function getName() { - return 'rapsys_air_application'; + public function getName(): string { + return 'rapsysair_application'; } } diff --git a/Form/ContactType.php b/Form/ContactType.php index bb0ee77..adee525 100644 --- a/Form/ContactType.php +++ b/Form/ContactType.php @@ -33,7 +33,7 @@ class ContactType extends CaptchaType { /** * {@inheritdoc} */ - public function configureOptions(OptionsResolver $resolver) { + public function configureOptions(OptionsResolver $resolver): void { //Set defaults $resolver->setDefaults(['error_bubbling' => true]); } @@ -41,7 +41,7 @@ class ContactType extends CaptchaType { /** * {@inheritdoc} */ - public function getName() { + public function getName(): string { return 'contact_form'; } } diff --git a/Form/ImageType.php b/Form/ImageType.php index d1f7de0..300ffe9 100644 --- a/Form/ImageType.php +++ b/Form/ImageType.php @@ -81,6 +81,6 @@ class ImageType extends AbstractType { * {@inheritdoc} */ public function getName(): string { - return 'rapsys_air_image'; + return 'rapsysair_image'; } } diff --git a/Form/LocationType.php b/Form/LocationType.php index ad4b945..0072d8b 100644 --- a/Form/LocationType.php +++ b/Form/LocationType.php @@ -30,8 +30,9 @@ class LocationType extends AbstractType { /** * {@inheritdoc} */ - public function buildForm(FormBuilderInterface $builder, array $options) { - return $builder + public function buildForm(FormBuilderInterface $builder, array $options): void { + //Build form + $builder ->add('title', TextType::class, ['attr' => ['placeholder' => 'Your title'], 'constraints' => [new NotBlank(['message' => 'Please provide your title'])]]) ->add('description', TextareaType::class, ['attr' => ['placeholder' => 'Your description', 'cols' => 50, 'rows' => 15], 'required' => false]) ->add('address', TextType::class, ['attr' => ['placeholder' => 'Your address'], 'constraints' => [new NotBlank(['message' => 'Please provide your address'])]]) @@ -47,7 +48,7 @@ class LocationType extends AbstractType { /** * {@inheritdoc} */ - public function configureOptions(OptionsResolver $resolver) { + public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults(['data_class' => Location::class, 'error_bubbling' => true]); } } diff --git a/Form/RegisterType.php b/Form/RegisterType.php index e6af083..e79a7dc 100644 --- a/Form/RegisterType.php +++ b/Form/RegisterType.php @@ -187,6 +187,6 @@ class RegisterType extends BaseRegisterType { * {@inheritdoc} */ public function getName(): string { - return 'rapsys_air_register'; + return 'rapsysair_register'; } } diff --git a/Form/SessionType.php b/Form/SessionType.php index ef42649..d6f1ba3 100644 --- a/Form/SessionType.php +++ b/Form/SessionType.php @@ -39,7 +39,7 @@ class SessionType extends AbstractType { * * {@inheritdoc} */ - public function buildForm(FormBuilderInterface $builder, array $options) { + public function buildForm(FormBuilderInterface $builder, array $options): void { //Is admin or user with rainfall >= 2 if (!empty($options['raincancel'])) { //Add raincancel item @@ -104,15 +104,12 @@ class SessionType extends AbstractType { ->add('autoattribute', SubmitType::class, ['label' => 'Auto attribute', 'attr' => ['class' => 'submit']]); } } - - //Return form - return $builder; } /** * {@inheritdoc} */ - public function configureOptions(OptionsResolver $resolver) { + public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults(['error_bubbling' => true, 'admin' => false, 'dance_choices' => [], 'dance_default' => null, 'dance_favorites' => [], 'date' => null, 'begin' => null, 'length' => null, 'cancel' => false, 'raincancel' => false, 'modify' => false, 'move' => false, 'attribute' => false, 'user' => null, 'session' => null, 'slot_default' => null]); //Add admin @@ -161,7 +158,7 @@ class SessionType extends AbstractType { /** * {@inheritdoc} */ - public function getName() { - return 'rapsys_air_session_edit'; + public function getName(): string { + return 'rapsysair_session_edit'; } } diff --git a/Form/SnippetType.php b/Form/SnippetType.php index 0bd8307..8f81b40 100644 --- a/Form/SnippetType.php +++ b/Form/SnippetType.php @@ -120,6 +120,6 @@ class SnippetType extends AbstractType { * {@inheritdoc} */ public function getName(): string { - return 'rapsys_air_snippet'; + return 'rapsysair_snippet'; } } -- 2.41.1