diff --git a/src/Bundle/ChillBudgetBundle/Form/ChargeType.php b/src/Bundle/ChillBudgetBundle/Form/ChargeType.php index da219abb9..6d0b9c7b6 100644 --- a/src/Bundle/ChillBudgetBundle/Form/ChargeType.php +++ b/src/Bundle/ChillBudgetBundle/Form/ChargeType.php @@ -1,42 +1,34 @@ configRepository = $configRepository; $this->translatableStringHelper = $translatableStringHelper; } - public function buildForm(FormBuilderInterface $builder, array $options) { $builder @@ -45,24 +37,23 @@ class ChargeType extends AbstractType 'placeholder' => 'Choose a charge type' ]) ->add('amount', MoneyType::class) - ->add('comment', TextAreaType::class, [ + ->add('comment', TextareaType::class, [ 'required' => false - ]) - ; - + ]); + if ($options['show_start_date']) { $builder->add('startDate', ChillDateType::class, [ 'label' => 'Start of validity period' ]); } - + if ($options['show_end_date']) { $builder->add('endDate', ChillDateType::class, [ 'required' => false, 'label' => 'End of validity period' ]); } - + if ($options['show_help']) { $builder->add('help', ChoiceType::class, [ 'choices' => [ @@ -77,48 +68,39 @@ class ChargeType extends AbstractType ]); } } - + private function getTypes() { $charges = $this->configRepository ->getChargesLabels(); - + // rewrite labels to filter in language foreach ($charges as $key => $labels) { $charges[$key] = $this->translatableStringHelper->localize($labels); } - + \asort($charges); - + return \array_flip($charges); } - - /** - * {@inheritdoc} - */ + public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( - 'data_class' => 'Chill\AMLI\BudgetBundle\Entity\Charge', + 'data_class' => Charge::class, 'show_start_date' => true, 'show_end_date' => true, 'show_help' => true )); - + $resolver ->setAllowedTypes('show_start_date', 'boolean') ->setAllowedTypes('show_end_date', 'boolean') - ->setAllowedTypes('show_help', 'boolean') - ; + ->setAllowedTypes('show_help', 'boolean'); } - /** - * {@inheritdoc} - */ public function getBlockPrefix() { return 'chill_amli_budgetbundle_charge'; } - - } diff --git a/src/Bundle/ChillBudgetBundle/Form/ResourceType.php b/src/Bundle/ChillBudgetBundle/Form/ResourceType.php index abf7191ab..2df9ee6d7 100644 --- a/src/Bundle/ChillBudgetBundle/Form/ResourceType.php +++ b/src/Bundle/ChillBudgetBundle/Form/ResourceType.php @@ -1,7 +1,10 @@ configRepository = $configRepository; $this->translatableStringHelper = $translatableStringHelper; } - public function buildForm(FormBuilderInterface $builder, array $options) { $builder @@ -45,17 +38,16 @@ class ResourceType extends AbstractType 'label' => 'Resource element type' ]) ->add('amount', MoneyType::class) - ->add('comment', TextAreaType::class, [ + ->add('comment', TextareaType::class, [ 'required' => false - ]) - ; - + ]); + if ($options['show_start_date']) { $builder->add('startDate', ChillDateType::class, [ 'label' => 'Start of validity period' ]); } - + if ($options['show_end_date']) { $builder->add('endDate', ChillDateType::class, [ 'required' => false, @@ -63,25 +55,7 @@ class ResourceType extends AbstractType ]); } } - - private function getTypes() - { - $resources = $this->configRepository - ->getResourcesLabels(); - - // rewrite labels to filter in language - foreach ($resources as $key => $labels) { - $resources[$key] = $this->translatableStringHelper->localize($labels); - } - - asort($resources); - - return \array_flip($resources); - } - - /** - * {@inheritdoc} - */ + public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( @@ -89,20 +63,29 @@ class ResourceType extends AbstractType 'show_start_date' => true, 'show_end_date' => true )); - + $resolver ->setAllowedTypes('show_start_date', 'boolean') - ->setAllowedTypes('show_end_date', 'boolean') - ; + ->setAllowedTypes('show_end_date', 'boolean'); } - /** - * {@inheritdoc} - */ public function getBlockPrefix() { return 'chill_amli_budgetbundle_resource'; } + private function getTypes() + { + $resources = $this->configRepository + ->getResourcesLabels(); + // rewrite labels to filter in language + foreach ($resources as $key => $labels) { + $resources[$key] = $this->translatableStringHelper->localize($labels); + } + + asort($resources); + + return \array_flip($resources); + } } diff --git a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php index 1f21defd9..f41d843c2 100644 --- a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php +++ b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php @@ -1,83 +1,49 @@ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ + +declare(strict_types=1); + namespace Chill\PersonBundle\Form\SocialWork; +use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; use Chill\MainBundle\Form\Type\TranslatableStringFormType; use Symfony\Component\Form\Extension\Core\Type\DateType; -use Chill\MainBundle\Templating\TranslatableStringHelper; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Chill\PersonBundle\Entity\SocialWork\SocialIssue; -/** - * Class SocialIssueType - * - * @package Chill\PersonBundle\Form - */ class SocialIssueType extends AbstractType { - /** - * - * @var TranslatableStringHelper - */ - protected $translatableStringHelper; + protected TranslatableStringHelperInterface $translatableStringHelper; - public function __construct(TranslatableStringHelper $translatableStringHelper) { + public function __construct( + TranslatableStringHelperInterface $translatableStringHelper + ) { $this->translatableStringHelper = $translatableStringHelper; } - /** - * @param FormBuilderInterface $builder - * @param array $options - */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('title', TranslatableStringFormType::class, [ 'label' => 'Nom' ]) - ->add('parent', EntityType::class, [ 'class' => SocialIssue::class, 'required' => false, - 'choice_label' => function (SocialIssue $issue) { - return $this->translatableStringHelper->localize($issue->getTitle()); - } + 'choice_label' => static fn (SocialIssue $issue): ?string => $this->translatableStringHelper->localize($issue->getTitle()) ]) - ->add('desactivationDate', DateType::class, [ 'attr' => ['class' => 'datepicker'], 'widget'=> 'single_text', 'format' => 'dd-MM-yyyy', 'required' => false, ]); -} + } - /** - * @param OptionsResolver $resolver - */ public function configureOptions(OptionsResolver $resolver) { - $resolver - ->setDefault('class', SocialIssue::class) - ; + $resolver->setDefault('class', SocialIssue::class); } }