mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
Merge branch 'master' into 'feature/add-requestor-in-search-results'
# Conflicts: # CHANGELOG.md
This commit is contained in:
@@ -513,6 +513,44 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array with open participations sorted by household
|
||||
* [
|
||||
* [
|
||||
* "household" => Household x,
|
||||
* "members" => [
|
||||
* Participation y , Participation z, ...
|
||||
* ]
|
||||
* ],
|
||||
* ]
|
||||
*
|
||||
*/
|
||||
public function actualParticipationsByHousehold(): array
|
||||
{
|
||||
$participations = $this->getOPenParticipations()->toArray();
|
||||
|
||||
$households = [];
|
||||
foreach ($participations as $p) {
|
||||
$households[] = $p->getPerson()->getCurrentHousehold();
|
||||
}
|
||||
$households = array_unique($households, SORT_REGULAR);
|
||||
|
||||
$array = [];
|
||||
foreach ($households as $household) {
|
||||
$members = [];
|
||||
foreach ($participations as $p) {
|
||||
if ($household === $p->getPerson()->getCurrentHousehold()) {
|
||||
$members[] = array_shift($participations);
|
||||
} else {
|
||||
$participations[] = array_shift($participations);
|
||||
}
|
||||
}
|
||||
$array[] = [ 'household' => $household, 'members' => $members ];
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the accompanying period contains a person.
|
||||
*
|
||||
|
Reference in New Issue
Block a user