mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Fixes phpstan
This commit is contained in:
parent
e6102d339b
commit
6781fdbd9b
@ -5,6 +5,7 @@ namespace Chill\MainBundle\Entity;
|
||||
use Chill\MainBundle\Repository\GenderRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['chill_main_gender' => Gender::class])]
|
||||
#[ORM\Entity(repositoryClass: GenderRepository::class)]
|
||||
|
@ -34,7 +34,7 @@ class GenderType extends AbstractType
|
||||
'multiple' => false,
|
||||
'mapped' => true,
|
||||
'choice_label' => fn(GenderIconEnum $enum) => '<i class="' . strtolower($enum->value) . '"></i>',
|
||||
'choice_value' => fn(?GenderIconEnum $enum) => $enum ? $enum->value : null,
|
||||
'choice_value' => fn(?GenderIconEnum $enum) => null !== $enum ? $enum->value : null,
|
||||
'label' => 'gender.admin.Select Gender Icon',
|
||||
'label_html' => true,
|
||||
])
|
||||
|
@ -1014,7 +1014,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
*
|
||||
* @deprecated Keep for legacy. Used in Chill 1.5 for feminize before icu translations
|
||||
*/
|
||||
public function getGenderNumeric()
|
||||
/* public function getGenderNumeric()
|
||||
{
|
||||
return match ($this->getGender()) {
|
||||
self::FEMALE_GENDER => 1,
|
||||
@ -1022,7 +1022,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
self::BOTH_GENDER => 2,
|
||||
default => -1,
|
||||
};
|
||||
}
|
||||
}*/
|
||||
|
||||
public function getHouseholdAddresses(): Collection
|
||||
{
|
||||
|
@ -12,6 +12,8 @@ declare(strict_types=1);
|
||||
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;
|
||||
@ -20,7 +22,7 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
final readonly class GenderAggregator implements AggregatorInterface
|
||||
{
|
||||
public function __construct(private TranslatorInterface $translator) {}
|
||||
public function __construct(private TranslatorInterface $translator, private TranslatableStringHelperInterface $translatableStringHelper, GenderRepository $repository) {}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
@ -48,30 +50,16 @@ final readonly class GenderAggregator implements AggregatorInterface
|
||||
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
return function ($value) {
|
||||
switch ($value) {
|
||||
case Person::FEMALE_GENDER:
|
||||
return $this->translator->trans('woman');
|
||||
|
||||
case Person::MALE_GENDER:
|
||||
return $this->translator->trans('man');
|
||||
|
||||
case Person::BOTH_GENDER:
|
||||
return $this->translator->trans('both');
|
||||
|
||||
case Person::NO_INFORMATION:
|
||||
return $this->translator->trans('unknown');
|
||||
|
||||
case null:
|
||||
case '':
|
||||
return $this->translator->trans('Not given');
|
||||
|
||||
case '_header':
|
||||
return $this->translator->trans('Gender');
|
||||
|
||||
default:
|
||||
throw new \LogicException(sprintf('The value %s is not valid', $value));
|
||||
return function (int|string|null $value) {
|
||||
if (null === $value || '' === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ('_header' === $value) {
|
||||
return $this->translator->trans('Gender');
|
||||
}
|
||||
|
||||
return (string) $this->translatableStringHelper->localize($this->repository->find((int) $value)?->getLabel());
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -11,13 +11,18 @@ 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;
|
||||
@ -26,14 +31,8 @@ class GenderFilter implements
|
||||
ExportElementValidatedInterface,
|
||||
FilterInterface
|
||||
{
|
||||
/**
|
||||
* @var TranslatorInterface
|
||||
*/
|
||||
protected $translator;
|
||||
|
||||
public function __construct(TranslatorInterface $translator)
|
||||
public function __construct(private TranslatorInterface $translator, private TranslatableStringHelperInterface $translatableStringHelper)
|
||||
{
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
@ -72,14 +71,9 @@ class GenderFilter implements
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add('accepted_genders', ChoiceType::class, [
|
||||
'choices' => [
|
||||
'Woman' => Person::FEMALE_GENDER,
|
||||
'Man' => Person::MALE_GENDER,
|
||||
'Both' => Person::BOTH_GENDER,
|
||||
'Unknown' => Person::NO_INFORMATION,
|
||||
'Not given' => 'null',
|
||||
],
|
||||
$builder->add('accepted_genders', EntityType::class, [
|
||||
'class' => Gender::class,
|
||||
'choice_label' => fn(Gender $g) => $this->translatableStringHelper->localize($g->getLabel()),
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
]);
|
||||
@ -98,7 +92,7 @@ class GenderFilter implements
|
||||
if ('null' === $g) {
|
||||
$genders[] = $this->translator->trans('Not given');
|
||||
} else {
|
||||
$genders[] = $this->translator->trans($g);
|
||||
$genders[] = $this->translatableStringHelper($g->getLabel());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Search;
|
||||
|
||||
use Chill\MainBundle\Form\GenderType;
|
||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
use Chill\MainBundle\Form\Type\ChillPhoneNumberType;
|
||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
@ -21,7 +22,6 @@ use Chill\MainBundle\Search\SearchInterface;
|
||||
use Chill\MainBundle\Search\Utils\ExtractDateFromPattern;
|
||||
use Chill\MainBundle\Search\Utils\ExtractPhonenumberFromPattern;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Form\Type\GenderType;
|
||||
use Chill\PersonBundle\Repository\PersonACLAwareRepositoryInterface;
|
||||
use libphonenumber\PhoneNumber;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
|
@ -94,7 +94,7 @@ class PersonDocGenNormalizer implements
|
||||
'age' => (int) $person->getAge(),
|
||||
'birthdate' => $this->normalizer->normalize($person->getBirthdate(), $format, $dateContext),
|
||||
'deathdate' => $this->normalizer->normalize($person->getDeathdate(), $format, $dateContext),
|
||||
'gender' => $this->translator->trans($person->getGender()),
|
||||
'gender' => $this$this->translator->trans($person->getGender()),
|
||||
'maritalStatus' => null !== ($ms = $person->getMaritalStatus()) ? $this->translatableStringHelper->localize($ms->getName()) : '',
|
||||
'maritalStatusDate' => $this->normalizer->normalize($person->getMaritalStatusDate(), $format, $dateContext),
|
||||
'maritalStatusComment' => $this->normalizer->normalize($person->getMaritalStatusComment(), $format, $dateContext),
|
||||
|
Loading…
x
Reference in New Issue
Block a user