mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-27 10:03:49 +00:00
DX: rector rules upt to PHP 74
This commit is contained in:
@@ -55,9 +55,7 @@ class PersonChoiceLoader implements ChoiceLoaderInterface
|
||||
{
|
||||
return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList(
|
||||
$this->lazyLoadedPersons,
|
||||
static function (Person $p) use ($value) {
|
||||
return call_user_func($value, $p);
|
||||
}
|
||||
static fn(Person $p) => call_user_func($value, $p)
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -40,9 +40,7 @@ class HouseholdCompositionType extends AbstractType
|
||||
->add('householdCompositionType', EntityType::class, [
|
||||
'class' => \Chill\PersonBundle\Entity\Household\HouseholdCompositionType::class,
|
||||
'choices' => $types,
|
||||
'choice_label' => function (\Chill\PersonBundle\Entity\Household\HouseholdCompositionType $type) {
|
||||
return $this->translatableStringHelper->localize($type->getLabel());
|
||||
},
|
||||
'choice_label' => fn(\Chill\PersonBundle\Entity\Household\HouseholdCompositionType $type) => $this->translatableStringHelper->localize($type->getLabel()),
|
||||
'label' => 'household_composition.Household composition',
|
||||
])
|
||||
->add('startDate', ChillDateType::class, [
|
||||
|
@@ -118,12 +118,8 @@ class PersonType extends AbstractType
|
||||
]);
|
||||
|
||||
$builder->get('placeOfBirth')->addModelTransformer(new CallbackTransformer(
|
||||
static function ($string) {
|
||||
return strtoupper((string) $string);
|
||||
},
|
||||
static function ($string) {
|
||||
return strtoupper((string) $string);
|
||||
}
|
||||
static fn($string) => strtoupper((string) $string),
|
||||
static fn($string) => strtoupper((string) $string)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -167,9 +163,7 @@ class PersonType extends AbstractType
|
||||
'allow_delete' => true,
|
||||
'by_reference' => false,
|
||||
'label' => false,
|
||||
'delete_empty' => static function (?PersonPhone $pp = null) {
|
||||
return null === $pp || $pp->isEmpty();
|
||||
},
|
||||
'delete_empty' => static fn(?PersonPhone $pp = null) => null === $pp || $pp->isEmpty(),
|
||||
'error_bubbling' => false,
|
||||
'empty_collection_explain' => 'No additional phone numbers',
|
||||
]);
|
||||
|
@@ -46,9 +46,7 @@ class GoalType extends AbstractType
|
||||
'class' => Result::class,
|
||||
'required' => false,
|
||||
'multiple' => true,
|
||||
'choice_label' => function (Result $r) {
|
||||
return $this->translatableStringHelper->localize($r->getTitle());
|
||||
},
|
||||
'choice_label' => fn(Result $r) => $this->translatableStringHelper->localize($r->getTitle()),
|
||||
'attr' => ['class' => 'select2 '],
|
||||
])
|
||||
->add('desactivationDate', ChillDateType::class, [
|
||||
|
@@ -50,16 +50,12 @@ class SocialActionType extends AbstractType
|
||||
->add('issue', EntityType::class, [
|
||||
'class' => SocialIssue::class,
|
||||
'label' => 'socialAction.socialIssue',
|
||||
'choice_label' => function (SocialIssue $issue) {
|
||||
return $this->translatableStringHelper->localize($issue->getTitle());
|
||||
},
|
||||
'choice_label' => fn(SocialIssue $issue) => $this->translatableStringHelper->localize($issue->getTitle()),
|
||||
])
|
||||
->add('parent', EntityType::class, [
|
||||
'class' => SocialAction::class,
|
||||
'required' => false,
|
||||
'choice_label' => function (SocialAction $issue) {
|
||||
return $this->translatableStringHelper->localize($issue->getTitle());
|
||||
},
|
||||
'choice_label' => fn(SocialAction $issue) => $this->translatableStringHelper->localize($issue->getTitle()),
|
||||
])
|
||||
->add('ordering', NumberType::class, [
|
||||
'required' => true,
|
||||
@@ -70,9 +66,7 @@ class SocialActionType extends AbstractType
|
||||
'required' => false,
|
||||
'multiple' => true,
|
||||
'attr' => ['class' => 'select2'],
|
||||
'choice_label' => function (Result $r) {
|
||||
return $this->translatableStringHelper->localize($r->getTitle());
|
||||
},
|
||||
'choice_label' => fn(Result $r) => $this->translatableStringHelper->localize($r->getTitle()),
|
||||
])
|
||||
|
||||
->add('goals', EntityType::class, [
|
||||
@@ -80,9 +74,7 @@ class SocialActionType extends AbstractType
|
||||
'required' => false,
|
||||
'multiple' => true,
|
||||
'attr' => ['class' => 'select2'],
|
||||
'choice_label' => function (Goal $g) {
|
||||
return $this->translatableStringHelper->localize($g->getTitle());
|
||||
},
|
||||
'choice_label' => fn(Goal $g) => $this->translatableStringHelper->localize($g->getTitle()),
|
||||
])
|
||||
|
||||
->add('evaluations', EntityType::class, [
|
||||
@@ -90,9 +82,7 @@ class SocialActionType extends AbstractType
|
||||
'required' => false,
|
||||
'multiple' => true,
|
||||
'attr' => ['class' => 'select2'],
|
||||
'choice_label' => function (Evaluation $e) {
|
||||
return $this->translatableStringHelper->localize($e->getTitle());
|
||||
},
|
||||
'choice_label' => fn(Evaluation $e) => $this->translatableStringHelper->localize($e->getTitle()),
|
||||
])
|
||||
|
||||
->add('defaultNotificationDelay', DateIntervalType::class, [
|
||||
|
@@ -60,18 +60,14 @@ class ClosingMotivePickerType extends AbstractType
|
||||
'class' => ClosingMotive::class,
|
||||
'empty_data' => null,
|
||||
'placeholder' => 'Choose a motive',
|
||||
'choice_label' => function (ClosingMotive $cm) {
|
||||
return $this->entityRenderExtension->renderString($cm);
|
||||
},
|
||||
'choice_label' => fn(ClosingMotive $cm) => $this->entityRenderExtension->renderString($cm),
|
||||
'only_leaf' => true,
|
||||
]);
|
||||
|
||||
$resolver
|
||||
->setAllowedTypes('only_leaf', 'bool')
|
||||
->setNormalizer('choices', function (Options $options) {
|
||||
return $this->repository
|
||||
->getActiveClosingMotive($options['only_leaf']);
|
||||
});
|
||||
->setNormalizer('choices', fn(Options $options) => $this->repository
|
||||
->getActiveClosingMotive($options['only_leaf']));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -113,15 +113,11 @@ class PickPersonType extends AbstractType
|
||||
// add the default options
|
||||
$resolver->setDefaults([
|
||||
'class' => Person::class,
|
||||
'choice_label' => static function (Person $p) {
|
||||
return $p->getFirstname() . ' ' . $p->getLastname();
|
||||
},
|
||||
'choice_label' => static fn(Person $p) => $p->getFirstname() . ' ' . $p->getLastname(),
|
||||
'placeholder' => 'Pick a person',
|
||||
'choice_attr' => static function (Person $p) {
|
||||
return [
|
||||
'data-center' => $p->getCenter()->getId(),
|
||||
];
|
||||
},
|
||||
'choice_attr' => static fn(Person $p) => [
|
||||
'data-center' => $p->getCenter()->getId(),
|
||||
],
|
||||
'attr' => ['class' => 'select2 '],
|
||||
'choice_loader' => function (Options $options) {
|
||||
$centers = $this->filterCentersfom($options);
|
||||
@@ -139,9 +135,7 @@ class PickPersonType extends AbstractType
|
||||
protected function filterCentersfom(Options $options)
|
||||
{
|
||||
if (null === $options['role']) {
|
||||
$centers = array_map(static function (GroupCenter $g) {
|
||||
return $g->getCenter();
|
||||
}, $this->user->getGroupCenters()->toArray());
|
||||
$centers = array_map(static fn(GroupCenter $g) => $g->getCenter(), $this->user->getGroupCenters()->toArray());
|
||||
} else {
|
||||
$centers = $this->authorizationHelper
|
||||
->getReachableCenters($this->user, $options['role']->getRole());
|
||||
@@ -164,9 +158,7 @@ class PickPersonType extends AbstractType
|
||||
|
||||
if (
|
||||
!in_array($c->getId(), array_map(
|
||||
static function (Center $c) {
|
||||
return $c->getId();
|
||||
},
|
||||
static fn(Center $c) => $c->getId(),
|
||||
$centers
|
||||
), true)
|
||||
) {
|
||||
|
@@ -38,9 +38,7 @@ class PickSocialActionType extends AbstractType
|
||||
->setDefaults([
|
||||
'class' => SocialAction::class,
|
||||
'choices' => $this->actionRepository->findAllActive(),
|
||||
'choice_label' => function (SocialAction $sa) {
|
||||
return $this->actionRender->renderString($sa, []);
|
||||
},
|
||||
'choice_label' => fn(SocialAction $sa) => $this->actionRender->renderString($sa, []),
|
||||
'placeholder' => 'Pick a social action',
|
||||
'required' => false,
|
||||
'attr' => ['class' => 'select2'],
|
||||
|
@@ -38,9 +38,7 @@ class PickSocialIssueType extends AbstractType
|
||||
->setDefaults([
|
||||
'class' => SocialIssue::class,
|
||||
'choices' => $this->issueRepository->findAllActive(),
|
||||
'choice_label' => function (SocialIssue $si) {
|
||||
return $this->issueRender->renderString($si, []);
|
||||
},
|
||||
'choice_label' => fn(SocialIssue $si) => $this->issueRender->renderString($si, []),
|
||||
'placeholder' => 'Pick a social issue',
|
||||
'required' => false,
|
||||
'attr' => ['class' => 'select2'],
|
||||
|
Reference in New Issue
Block a user