From 7fbb3dfd07d10f03e16d513f264d208525368354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 11 Apr 2022 17:43:31 +0200 Subject: [PATCH] docgen: add more persons choices in person1, person2 and mainPerson Allow to pick amongst: * requestor (if person) * resources of course (if person) * resources of person (if person) --- .../AccompanyingPeriodContext.php | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php index 495989b29..dc6e9c912 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php @@ -152,8 +152,25 @@ class AccompanyingPeriodContext implements $options = $template->getOptions(); $persons = $entity->getCurrentParticipations()->map(static function (AccompanyingPeriodParticipation $p) { return $p->getPerson(); - }) - ->toArray(); + }); + + foreach ($entity->getCurrentParticipations() as $p) { + foreach ($p->getPerson()->getResources() as $r) { + if (null !== $r->getPerson() && !$persons->contains($r->getPerson())) { + $persons->add($r->getPerson()); + } + } + } + + if (null !== $entity->getRequestorPerson() && !$persons->contains($entity->getRequestorPerson())) { + $persons->add($entity->getRequestorPerson()); + } + + foreach ($entity->getResources() as $r) { + if (null !== $r->getPerson() && !$persons->contains($r->getPerson())) { + $persons->add($r->getPerson()); + } + } foreach (['mainPerson', 'person1', 'person2'] as $key) { if ($options[$key] ?? false) {