DX: use array spred instead of array_merge

This commit is contained in:
Julien Fastré 2023-05-31 23:47:02 +02:00
parent 80dfa092db
commit 9c109d2efd
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
3 changed files with 33 additions and 43 deletions

View File

@ -213,17 +213,14 @@ class AccompanyingPeriodContext implements
}
}
$thirdParties = array_merge(
array_values(array_filter([$entity->getRequestorThirdParty()])),
array_values(array_filter(
$thirdParties = [...array_values(array_filter([$entity->getRequestorThirdParty()])), ...array_values(array_filter(
array_map(
fn (Resource $r): ?ThirdParty => $r->getThirdParty(),
$entity->getResources()->filter(
static fn (Resource $r): bool => null !== $r->getThirdParty()
)->toArray()
)
))
);
))];
if ($options['thirdParty'] ?? false) {
$builder->add('thirdParty', EntityType::class, [

View File

@ -116,10 +116,7 @@ class AccompanyingPeriodWorkEvaluationContext implements
{
$this->accompanyingPeriodWorkContext->buildPublicForm($builder, $template, $entity->getAccompanyingPeriodWork());
$thirdParties = array_merge(
array_values(array_filter($entity->getAccompanyingPeriodWork()->getThirdParties()->toArray())),
array_values(array_filter([$entity->getAccompanyingPeriodWork()->getHandlingThierParty()])),
array_values(
$thirdParties = [...array_values(array_filter($entity->getAccompanyingPeriodWork()->getThirdParties()->toArray())), ...array_values(array_filter([$entity->getAccompanyingPeriodWork()->getHandlingThierParty()])), ...array_values(
array_filter(
array_map(
fn (Resource $r): ?ThirdParty => $r->getThirdParty(),
@ -128,8 +125,7 @@ class AccompanyingPeriodWorkEvaluationContext implements
)->toArray()
)
)
)
);
)];
$options = $template->getOptions();
if ($options['thirdParty'] ?? false) {

View File

@ -179,8 +179,7 @@ final class PersonContext implements PersonContextInterface
'data' => $this->translatableStringHelper->localize($template->getName()),
]);
$thirdParties = array_merge(
array_values(
$thirdParties = [...array_values(
array_filter(
array_map(
fn (ResidentialAddress $r): ?ThirdParty => $r->getHostThirdParty(),
@ -189,8 +188,7 @@ final class PersonContext implements PersonContextInterface
->findCurrentResidentialAddressByPerson($entity)
)
)
),
array_values(
), ...array_values(
array_filter(
array_map(
fn (PersonResource $r): ?ThirdParty => $r->getThirdParty(),
@ -199,8 +197,7 @@ final class PersonContext implements PersonContextInterface
)->toArray()
)
)
)
);
)];
if ($options['thirdParty'] ?? false) {
$builder->add('thirdParty', EntityType::class, [