mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 22:35:01 +00:00
rdv: add thirdParty in concerned persons (WIP)
This commit is contained in:
@@ -14,6 +14,7 @@ use Chill\CalendarBundle\Entity\Calendar;
|
||||
use Chill\CalendarBundle\Entity\CancelReason;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Symfony\Component\Form\CallbackTransformer;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
|
||||
@@ -81,7 +82,45 @@ class CalendarType extends AbstractType
|
||||
}
|
||||
))
|
||||
;
|
||||
|
||||
|
||||
$builder->add('professionals', HiddenType::class);
|
||||
$builder->get('professionals')
|
||||
->addModelTransformer(new CallbackTransformer(
|
||||
function (iterable $thirdpartyAsIterable): string {
|
||||
$thirdpartyIds = [];
|
||||
foreach ($thirdpartyAsIterable as $value) {
|
||||
$thirdpartyIds[] = $value->getId();
|
||||
}
|
||||
return implode(',', $thirdpartyIds);
|
||||
},
|
||||
function (?string $thirdpartyAsString): array {
|
||||
return array_map(
|
||||
fn(string $id): ?ThirdParty => $this->om->getRepository(ThirdParty::class)->findOneBy(['id' => (int) $id]),
|
||||
explode(',', $thirdpartyAsString)
|
||||
);
|
||||
}
|
||||
))
|
||||
;
|
||||
|
||||
// $builder->add('users', HiddenType::class);
|
||||
// $builder->get('users')
|
||||
// ->addModelTransformer(new CallbackTransformer(
|
||||
// function (iterable $usersAsIterable): string {
|
||||
// $userIds = [];
|
||||
// foreach ($usersAsIterable as $value) {
|
||||
// $userIds[] = $value->getId();
|
||||
// }
|
||||
// return implode(',', $userIds);
|
||||
// },
|
||||
// function (?string $usersAsString): array {
|
||||
// return array_map(
|
||||
// fn(string $id): ?User => $this->om->getRepository(User::class)->findOneBy(['id' => (int) $id]),
|
||||
// explode(',', $usersAsString)
|
||||
// );
|
||||
// }
|
||||
// ))
|
||||
// ;
|
||||
|
||||
|
||||
}/**
|
||||
* {@inheritdoc}
|
||||
|
Reference in New Issue
Block a user