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)
This commit is contained in:
Julien Fastré 2022-04-11 17:43:31 +02:00
parent 9765bc5663
commit 7fbb3dfd07

View File

@ -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) {