mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Php cs fixes and phpstan
This commit is contained in:
parent
73b0dd6009
commit
f1844ae02b
@ -34,4 +34,14 @@ class GenderRepository extends ServiceEntityRepository
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
public function findByGenderTranslation($gender): array
|
||||
{
|
||||
return $this->createQueryBuilder('g')
|
||||
->select('g')
|
||||
->where('g.genderTranslation = :gender')
|
||||
->setParameter('gender', $gender)
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
|
||||
*/
|
||||
public function getRandomGender(): string
|
||||
{
|
||||
return $this->genders[array_rand($this->genders)->value];
|
||||
return $this->genders[array_rand($this->genders)];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -30,8 +30,11 @@ class GenderFilter implements
|
||||
DataTransformerInterface
|
||||
{
|
||||
// inject gender repository and find the active genders so that you can pass them to the ChoiceType (ordered by ordering)
|
||||
public function __construct(private readonly TranslatorInterface $translator, private readonly TranslatableStringHelperInterface $translatableStringHelper,
|
||||
private readonly GenderRepository $genderRepository) {}
|
||||
public function __construct(
|
||||
private readonly TranslatorInterface $translator,
|
||||
private readonly TranslatableStringHelperInterface $translatableStringHelper,
|
||||
private readonly GenderRepository $genderRepository
|
||||
) {}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
@ -44,7 +47,7 @@ class GenderFilter implements
|
||||
$isIn = $qb->expr()->in('person.gender', ':person_gender');
|
||||
|
||||
$acceptedGenders = $data['accepted_genders_entity'];
|
||||
$nullIncluded = in_array(null, $acceptedGenders, true);
|
||||
$nullIncluded = in_array(null, $acceptedGenders ?? [], true);
|
||||
|
||||
if (!$nullIncluded) {
|
||||
$clause = $isIn;
|
||||
@ -53,7 +56,7 @@ class GenderFilter implements
|
||||
}
|
||||
|
||||
$qb->andWhere($clause);
|
||||
$qb->setParameter('person_gender', array_filter($acceptedGenders, fn ($gender) => null !== $gender));
|
||||
$qb->setParameter('person_gender', array_filter($acceptedGenders ?? [], fn ($gender) => null !== $gender));
|
||||
}
|
||||
|
||||
public function applyOn()
|
||||
@ -80,6 +83,7 @@ class GenderFilter implements
|
||||
|
||||
public function transformData(?array $before): array
|
||||
{
|
||||
$transformedData = [];
|
||||
$transformedData['accepted_genders_entity'] = $before['accepted_genders_entity'] ?? [];
|
||||
|
||||
if (array_key_exists('accepted_genders', $before)) {
|
||||
|
@ -112,6 +112,7 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf
|
||||
$string .= !isset($data['phonenumber']) ? '' : 'phonenumber:'.$data['phonenumber']->getNationalNumber();
|
||||
|
||||
$string .= !isset($data['gender']) ? '' : 'gender:"'.$data['gender']->getId().'"';
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Tests\Export\Filter\PersonFilters;
|
||||
|
||||
use Chill\MainBundle\Entity\GenderEnum;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Export\Filter\PersonFilters\GenderFilter;
|
||||
|
Loading…
x
Reference in New Issue
Block a user