mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-22 23:53:50 +00:00
DX: rector rules upt to PHP 74
This commit is contained in:
@@ -48,9 +48,7 @@ class PostalCodeChoiceLoader implements ChoiceLoaderInterface
|
||||
{
|
||||
return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList(
|
||||
$this->lazyLoadedPostalCodes,
|
||||
static function (?PostalCode $pc = null) use ($value) {
|
||||
return call_user_func($value, $pc);
|
||||
}
|
||||
static fn(?PostalCode $pc = null) => call_user_func($value, $pc)
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -37,9 +37,7 @@ class ExportPickCenterDataMapper implements DataMapperInterface
|
||||
|
||||
foreach ($this->regroupmentRepository->findAll() as $regroupment) {
|
||||
/** @phpstan-ignore-next-line */
|
||||
[$contained, $notContained] = $regroupment->getCenters()->partition(static function (Center $center): bool {
|
||||
return false;
|
||||
});
|
||||
[$contained, $notContained] = $regroupment->getCenters()->partition(static fn(Center $center): bool => false);
|
||||
|
||||
if (0 === count($notContained)) {
|
||||
$pickedRegroupment[] = $regroupment;
|
||||
|
@@ -42,9 +42,7 @@ class IdToEntityDataTransformer implements DataTransformerInterface
|
||||
{
|
||||
$this->repository = $repository;
|
||||
$this->multiple = $multiple;
|
||||
$this->getId = $getId ?? static function (object $o) {
|
||||
return $o->getId();
|
||||
};
|
||||
$this->getId = $getId ?? static fn(object $o) => $o->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -36,15 +36,11 @@ final class LocationFormType extends AbstractType
|
||||
$builder
|
||||
->add('locationType', EntityType::class, [
|
||||
'class' => EntityLocationType::class,
|
||||
'choice_attr' => static function (EntityLocationType $entity) {
|
||||
return [
|
||||
'data-address' => $entity->getAddressRequired(),
|
||||
'data-contact' => $entity->getContactData(),
|
||||
];
|
||||
},
|
||||
'choice_label' => function (EntityLocationType $entity) {
|
||||
return $this->translatableStringHelper->localize($entity->getTitle());
|
||||
},
|
||||
'choice_attr' => static fn(EntityLocationType $entity) => [
|
||||
'data-address' => $entity->getAddressRequired(),
|
||||
'data-contact' => $entity->getContactData(),
|
||||
],
|
||||
'choice_label' => fn(EntityLocationType $entity) => $this->translatableStringHelper->localize($entity->getTitle()),
|
||||
])
|
||||
->add('name', TextType::class)
|
||||
->add('phonenumber1', ChillPhoneNumberType::class, ['required' => false])
|
||||
|
@@ -24,14 +24,10 @@ class ComposedGroupCenterType extends AbstractType
|
||||
{
|
||||
$builder->add('permissionsgroup', EntityType::class, [
|
||||
'class' => \Chill\MainBundle\Entity\PermissionsGroup::class,
|
||||
'choice_label' => static function (PermissionsGroup $group) {
|
||||
return $group->getName();
|
||||
},
|
||||
'choice_label' => static fn(PermissionsGroup $group) => $group->getName(),
|
||||
])->add('center', EntityType::class, [
|
||||
'class' => \Chill\MainBundle\Entity\Center::class,
|
||||
'choice_label' => static function (Center $center) {
|
||||
return $center->getName();
|
||||
},
|
||||
'choice_label' => static fn(Center $center) => $center->getName(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@@ -82,15 +82,11 @@ class ComposedRoleScopeType extends AbstractType
|
||||
|
||||
return ['data-has-scope' => '1'];
|
||||
},
|
||||
'group_by' => function ($role, $key, $index) {
|
||||
return $this->roleProvider->getRoleTitle($role);
|
||||
},
|
||||
'group_by' => fn($role, $key, $index) => $this->roleProvider->getRoleTitle($role),
|
||||
])
|
||||
->add('scope', EntityType::class, [
|
||||
'class' => Scope::class,
|
||||
'choice_label' => static function (Scope $scope) use ($translatableStringHelper) {
|
||||
return $translatableStringHelper->localize($scope->getName());
|
||||
},
|
||||
'choice_label' => static fn(Scope $scope) => $translatableStringHelper->localize($scope->getName()),
|
||||
'required' => false,
|
||||
'data' => null,
|
||||
]);
|
||||
|
@@ -51,9 +51,7 @@ class EntityToJsonTransformer implements DataTransformerInterface
|
||||
}
|
||||
|
||||
return array_map(
|
||||
function ($item) {
|
||||
return $this->denormalizeOne($item);
|
||||
},
|
||||
fn($item) => $this->denormalizeOne($item),
|
||||
$denormalized
|
||||
);
|
||||
}
|
||||
|
@@ -67,9 +67,7 @@ final class PickCenterType extends AbstractType
|
||||
'choices' => $centers,
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
'choice_label' => static function (Center $c) {
|
||||
return $c->getName();
|
||||
},
|
||||
'choice_label' => static fn(Center $c) => $c->getName(),
|
||||
'data' => $centers,
|
||||
]);
|
||||
|
||||
@@ -80,9 +78,7 @@ final class PickCenterType extends AbstractType
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
'choices' => $this->regroupmentRepository->findAllActive(),
|
||||
'choice_label' => static function (Regroupment $r) {
|
||||
return $r->getName();
|
||||
},
|
||||
'choice_label' => static fn(Regroupment $r) => $r->getName(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@@ -90,9 +90,7 @@ class PickCenterType extends AbstractType
|
||||
|
||||
return ['center' => $data];
|
||||
},
|
||||
static function ($data) {
|
||||
return $data['center'];
|
||||
}
|
||||
static fn($data) => $data['center']
|
||||
));
|
||||
}
|
||||
|
||||
|
@@ -34,17 +34,13 @@ class PickCivilityType extends AbstractType
|
||||
->setDefault('label', 'Civility')
|
||||
->setDefault(
|
||||
'choice_label',
|
||||
function (Civility $civility): string {
|
||||
return $this->translatableStringHelper->localize($civility->getName());
|
||||
}
|
||||
fn(Civility $civility): string => $this->translatableStringHelper->localize($civility->getName())
|
||||
)
|
||||
->setDefault(
|
||||
'query_builder',
|
||||
static function (EntityRepository $er): QueryBuilder {
|
||||
return $er->createQueryBuilder('c')
|
||||
->where('c.active = true')
|
||||
->orderBy('c.order');
|
||||
},
|
||||
static fn(EntityRepository $er): QueryBuilder => $er->createQueryBuilder('c')
|
||||
->where('c.active = true')
|
||||
->orderBy('c.order'),
|
||||
)
|
||||
->setDefault('placeholder', 'choose civility')
|
||||
->setDefault('class', Civility::class);
|
||||
|
@@ -31,9 +31,7 @@ class PickLocationTypeType extends AbstractType
|
||||
$resolver
|
||||
->setDefaults([
|
||||
'class' => LocationType::class,
|
||||
'choice_label' => function (LocationType $type) {
|
||||
return $this->translatableStringHelper->localize($type->getTitle());
|
||||
},
|
||||
'choice_label' => fn(LocationType $type) => $this->translatableStringHelper->localize($type->getTitle()),
|
||||
'placeholder' => 'Pick a location type',
|
||||
'required' => false,
|
||||
'attr' => ['class' => 'select2'],
|
||||
|
@@ -36,11 +36,9 @@ class PickUserLocationType extends AbstractType
|
||||
->setDefaults([
|
||||
'class' => Location::class,
|
||||
'choices' => $this->locationRepository->findByPublicLocations(),
|
||||
'choice_label' => function (Location $entity) {
|
||||
return $entity->getName() ?
|
||||
$entity->getName() . ' (' . $this->translatableStringHelper->localize($entity->getLocationType()->getTitle()) . ')' :
|
||||
$this->translatableStringHelper->localize($entity->getLocationType()->getTitle());
|
||||
},
|
||||
'choice_label' => fn(Location $entity) => $entity->getName() ?
|
||||
$entity->getName() . ' (' . $this->translatableStringHelper->localize($entity->getLocationType()->getTitle()) . ')' :
|
||||
$this->translatableStringHelper->localize($entity->getLocationType()->getTitle()),
|
||||
'placeholder' => 'Pick a location',
|
||||
'required' => false,
|
||||
'attr' => ['class' => 'select2'],
|
||||
|
@@ -77,10 +77,8 @@ class PostalCodeType extends AbstractType
|
||||
$helper = $this->translatableStringHelper;
|
||||
$resolver
|
||||
->setDefault('class', PostalCode::class)
|
||||
->setDefault('choice_label', static function (PostalCode $code) use ($helper) {
|
||||
return $code->getCode() . ' ' . $code->getName() . ' [' .
|
||||
$helper->localize($code->getCountry()->getName()) . ']';
|
||||
})
|
||||
->setDefault('choice_label', static fn(PostalCode $code) => $code->getCode() . ' ' . $code->getName() . ' [' .
|
||||
$helper->localize($code->getCountry()->getName()) . ']')
|
||||
->setDefault('choice_loader', $this->choiceLoader)
|
||||
->setDefault('placeholder', 'Select a postal code');
|
||||
}
|
||||
|
@@ -66,9 +66,7 @@ class ScopePickerType extends AbstractType
|
||||
$options['role'] instanceof Role ? $options['role']->getRole() : $options['role'],
|
||||
$options['center']
|
||||
),
|
||||
static function (Scope $s) {
|
||||
return $s->isActive();
|
||||
}
|
||||
static fn(Scope $s) => $s->isActive()
|
||||
);
|
||||
|
||||
if (0 === count($items)) {
|
||||
@@ -79,9 +77,7 @@ class ScopePickerType extends AbstractType
|
||||
$builder->add('scope', EntityType::class, [
|
||||
'class' => Scope::class,
|
||||
'placeholder' => 'Choose the circle',
|
||||
'choice_label' => function (Scope $c) {
|
||||
return $this->translatableStringHelper->localize($c->getName());
|
||||
},
|
||||
'choice_label' => fn(Scope $c) => $this->translatableStringHelper->localize($c->getName()),
|
||||
'choices' => $items,
|
||||
]);
|
||||
$builder->setDataMapper(new ScopePickerDataMapper());
|
||||
|
@@ -79,9 +79,7 @@ class UserPickerType extends AbstractType
|
||||
->setAllowedTypes('having_permissions_group_flag', ['string', 'null'])
|
||||
->setDefault('class', User::class)
|
||||
->setDefault('placeholder', 'Choose an user')
|
||||
->setDefault('choice_label', function (User $u) {
|
||||
return $this->userRender->renderString($u, []);
|
||||
})
|
||||
->setDefault('choice_label', fn(User $u) => $this->userRender->renderString($u, []))
|
||||
->setDefault('scope', null)
|
||||
->setAllowedTypes('scope', [Scope::class, 'array', 'null'])
|
||||
->setNormalizer('choices', function (Options $options) {
|
||||
|
@@ -77,18 +77,14 @@ class UserType extends AbstractType
|
||||
'required' => false,
|
||||
'placeholder' => 'Choose a main scope',
|
||||
'class' => Scope::class,
|
||||
'choice_label' => function (Scope $c) {
|
||||
return $this->translatableStringHelper->localize($c->getName());
|
||||
},
|
||||
'choice_label' => fn(Scope $c) => $this->translatableStringHelper->localize($c->getName()),
|
||||
])
|
||||
->add('userJob', EntityType::class, [
|
||||
'label' => 'user job',
|
||||
'required' => false,
|
||||
'placeholder' => 'choose a job',
|
||||
'class' => UserJob::class,
|
||||
'choice_label' => function (UserJob $c) {
|
||||
return $this->translatableStringHelper->localize($c->getLabel());
|
||||
},
|
||||
'choice_label' => fn(UserJob $c) => $this->translatableStringHelper->localize($c->getLabel()),
|
||||
'query_builder' => static function (EntityRepository $er) {
|
||||
$qb = $er->createQueryBuilder('uj');
|
||||
$qb->where('uj.active = TRUE');
|
||||
@@ -101,9 +97,7 @@ class UserType extends AbstractType
|
||||
'required' => false,
|
||||
'placeholder' => 'choose a location',
|
||||
'class' => Location::class,
|
||||
'choice_label' => function (Location $l) {
|
||||
return $this->translatableStringHelper->localize($l->getLocationType()->getTitle()) . ' - ' . $l->getName();
|
||||
},
|
||||
'choice_label' => fn(Location $l) => $this->translatableStringHelper->localize($l->getLocationType()->getTitle()) . ' - ' . $l->getName(),
|
||||
'query_builder' => static function (EntityRepository $er) {
|
||||
$qb = $er->createQueryBuilder('l');
|
||||
$qb->orderBy('l.locationType');
|
||||
|
@@ -69,9 +69,7 @@ class WorkflowStepType extends AbstractType
|
||||
|
||||
$choices = array_combine(
|
||||
array_map(
|
||||
static function (Transition $transition) {
|
||||
return $transition->getName();
|
||||
},
|
||||
static fn(Transition $transition) => $transition->getName(),
|
||||
$transitions
|
||||
),
|
||||
$transitions
|
||||
@@ -88,14 +86,10 @@ class WorkflowStepType extends AbstractType
|
||||
'backward' => 'backward',
|
||||
'neutral' => 'neutral',
|
||||
],
|
||||
'choice_label' => function (string $key) use ($inputLabels) {
|
||||
return $this->translatableStringHelper->localize($inputLabels[$key]);
|
||||
},
|
||||
'choice_attr' => static function (string $key) {
|
||||
return [
|
||||
$key => $key,
|
||||
];
|
||||
},
|
||||
'choice_label' => fn(string $key) => $this->translatableStringHelper->localize($inputLabels[$key]),
|
||||
'choice_attr' => static fn(string $key) => [
|
||||
$key => $key,
|
||||
],
|
||||
'mapped' => false,
|
||||
'expanded' => true,
|
||||
'data' => 'forward',
|
||||
|
Reference in New Issue
Block a user