From 59f9ac25baf801b77a4fcfe1ac88a9b6930452dd Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 8 Oct 2024 16:49:54 +0200 Subject: [PATCH] php cs fixes --- .../Controller/GenderApiController.php | 11 +++++++++- .../Controller/GenderController.php | 9 ++++++++ src/Bundle/ChillMainBundle/Entity/Gender.php | 9 ++++++++ .../ChillMainBundle/Entity/GenderEnum.php | 11 +++++++++- .../ChillMainBundle/Entity/GenderIconEnum.php | 9 ++++++++ .../ChillMainBundle/Form/GenderType.php | 21 +++++++++++-------- .../Repository/GenderRepository.php | 15 +++++++++---- .../Entity/ChillGenderIconRender.php | 4 +--- .../migrations/Version20240926093955.php | 7 +++++++ .../DataFixtures/ORM/LoadPeople.php | 7 ++++--- .../ChillPersonBundle/Entity/Person.php | 18 ++++++++-------- .../PersonAggregators/GenderAggregator.php | 1 - .../Filter/PersonFilters/GenderFilter.php | 12 +++-------- .../Form/Type/PickGenderType.php | 2 -- .../migrations/Version20240926100337.php | 7 +++++++ 15 files changed, 101 insertions(+), 42 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Controller/GenderApiController.php b/src/Bundle/ChillMainBundle/Controller/GenderApiController.php index 567756ba7..fd47afb85 100644 --- a/src/Bundle/ChillMainBundle/Controller/GenderApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/GenderApiController.php @@ -1,5 +1,14 @@ addOrderBy('e.order', 'ASC'); } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillMainBundle/Controller/GenderController.php b/src/Bundle/ChillMainBundle/Controller/GenderController.php index 8a949294f..a556145d4 100644 --- a/src/Bundle/ChillMainBundle/Controller/GenderController.php +++ b/src/Bundle/ChillMainBundle/Controller/GenderController.php @@ -1,5 +1,14 @@ add('label', TranslatableStringFormType::class, [ 'required' => true, ]) -/* ->add('icon', EnumType::class, [ - 'class' => GenderIconEnum::class, - 'label_html' => true, - 'expanded' => false, - 'mapped' => true, - ])*/ ->add('icon', ChoiceType::class, [ 'choices' => GenderIconEnum::cases(), 'expanded' => true, 'multiple' => false, 'mapped' => true, - 'choice_label' => fn(GenderIconEnum $enum) => '', - 'choice_value' => fn(?GenderIconEnum $enum) => null !== $enum ? $enum->value : null, + 'choice_label' => fn (GenderIconEnum $enum) => '', + 'choice_value' => fn (?GenderIconEnum $enum) => null !== $enum ? $enum->value : null, 'label' => 'gender.admin.Select Gender Icon', 'label_html' => true, ]) ->add('genderTranslation', EnumType::class, [ 'class' => GenderEnum::class, + 'choice_label' => fn (GenderEnum $enum) => $enum->value, 'label' => 'gender.admin.Select Gender Translation', ]) ->add('active', ChoiceType::class, [ diff --git a/src/Bundle/ChillMainBundle/Repository/GenderRepository.php b/src/Bundle/ChillMainBundle/Repository/GenderRepository.php index 438f49d95..9c10bdc38 100644 --- a/src/Bundle/ChillMainBundle/Repository/GenderRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/GenderRepository.php @@ -1,15 +1,22 @@ @@ -21,8 +20,7 @@ final readonly class ChillGenderIconRender implements ChillEntityRenderInterface { public function renderBox($icon, array $options): string { - return - ''; + return ''; } public function renderString($icon, array $options): string diff --git a/src/Bundle/ChillMainBundle/migrations/Version20240926093955.php b/src/Bundle/ChillMainBundle/migrations/Version20240926093955.php index 99626f521..50da93e33 100644 --- a/src/Bundle/ChillMainBundle/migrations/Version20240926093955.php +++ b/src/Bundle/ChillMainBundle/migrations/Version20240926093955.php @@ -2,6 +2,13 @@ declare(strict_types=1); +/* + * Chill is a software for social workers + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + namespace Chill\Migrations\Main; use Doctrine\DBAL\Schema\Schema; diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php index d356cf9ad..c5cb71d60 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php @@ -15,6 +15,7 @@ use Chill\MainBundle\DataFixtures\ORM\LoadPostalCodes; use Chill\MainBundle\Entity\Address; use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\Country; +use Chill\MainBundle\Entity\GenderEnum; use Chill\MainBundle\Entity\PostalCode; use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Entity\User; @@ -81,7 +82,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord protected NativeLoader $loader; - private array $genders = [Person::MALE_GENDER, Person::FEMALE_GENDER, Person::BOTH_GENDER]; + private array $genders = [GenderEnum::MALE, GenderEnum::FEMALE, GenderEnum::NEUTRAL]; private array $peoples = [ [ @@ -90,7 +91,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord 'birthdate' => '1948-12-27', 'placeOfBirth' => 'Châteauroux', 'nationality' => 'RU', - 'gender' => Person::MALE_GENDER, + 'gender' => GenderEnum::MALE, 'center' => 'Center A', 'accompanyingPeriods' => [ [ @@ -131,7 +132,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord 'lastName' => 'Depardieu', 'firstName' => 'Charline', 'birthdate' => '1970-10-15', - 'gender' => Person::FEMALE_GENDER, + 'gender' => GenderEnum::FEMALE, 'center' => 'Center A', 'maritalStatus' => 'ms_legalco', ], diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index 968763bff..5e880e107 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -1014,15 +1014,15 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * * @deprecated Keep for legacy. Used in Chill 1.5 for feminize before icu translations */ -/* public function getGenderNumeric() - { - return match ($this->getGender()) { - self::FEMALE_GENDER => 1, - self::MALE_GENDER => 0, - self::BOTH_GENDER => 2, - default => -1, - }; - }*/ + /* public function getGenderNumeric() + { + return match ($this->getGender()) { + self::FEMALE_GENDER => 1, + self::MALE_GENDER => 0, + self::BOTH_GENDER => 2, + default => -1, + }; + }*/ public function getHouseholdAddresses(): Collection { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GenderAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GenderAggregator.php index 033b89a2f..a2c656c5c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GenderAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GenderAggregator.php @@ -14,7 +14,6 @@ namespace Chill\PersonBundle\Export\Aggregator\PersonAggregators; use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Repository\GenderRepository; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; -use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Export\Declarations; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php index a45aa37ef..f5a216619 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php @@ -12,17 +12,13 @@ declare(strict_types=1); namespace Chill\PersonBundle\Export\Filter\PersonFilters; use Chill\MainBundle\Entity\Gender; -use Chill\MainBundle\Entity\GenderEnum; use Chill\MainBundle\Export\ExportElementValidatedInterface; use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; -use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Export\Declarations; use Doctrine\ORM\Query\Expr; use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\EnumType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Contracts\Translation\TranslatorInterface; @@ -31,9 +27,7 @@ class GenderFilter implements ExportElementValidatedInterface, FilterInterface { - public function __construct(private TranslatorInterface $translator, private TranslatableStringHelperInterface $translatableStringHelper) - { - } + public function __construct(private TranslatorInterface $translator, private TranslatableStringHelperInterface $translatableStringHelper) {} public function addRole(): ?string { @@ -73,7 +67,7 @@ class GenderFilter implements { $builder->add('accepted_genders', EntityType::class, [ 'class' => Gender::class, - 'choice_label' => fn(Gender $g) => $this->translatableStringHelper->localize($g->getLabel()), + 'choice_label' => fn (Gender $g) => $this->translatableStringHelper->localize($g->getLabel()), 'multiple' => true, 'expanded' => true, ]); @@ -92,7 +86,7 @@ class GenderFilter implements if ('null' === $g) { $genders[] = $this->translator->trans('Not given'); } else { - $genders[] = $this->translatableStringHelper($g->getLabel()); + $genders[] = $this->translatableStringHelper->localize($g->getLabel()); } } diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickGenderType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickGenderType.php index 4d4552caf..1e0c004d5 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickGenderType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickGenderType.php @@ -13,12 +13,10 @@ namespace Chill\PersonBundle\Form\Type; use Chill\MainBundle\Entity\Gender; use Chill\MainBundle\Templating\TranslatableStringHelper; -use Chill\PersonBundle\Entity\Person; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\OptionsResolver\OptionsResolver; /** diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20240926100337.php b/src/Bundle/ChillPersonBundle/migrations/Version20240926100337.php index 021533efd..0475154a4 100644 --- a/src/Bundle/ChillPersonBundle/migrations/Version20240926100337.php +++ b/src/Bundle/ChillPersonBundle/migrations/Version20240926100337.php @@ -2,6 +2,13 @@ declare(strict_types=1); +/* + * Chill is a software for social workers + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + namespace Chill\Migrations\Person; use Doctrine\DBAL\Schema\Schema;