method added to get current accompanying periods + api adjusted

This commit is contained in:
2021-11-05 17:00:07 +01:00
parent cab7cc4150
commit f064e8f307
2 changed files with 21 additions and 1 deletions

View File

@@ -613,6 +613,26 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $accompanyingPeriods;
}
/**
* Get current accompanyingPeriods array
*/
public function getCurrentAccompanyingPeriods(): array
{
$currentAccompanyingPeriods = [];
$currentDate = new DateTime();
foreach ($this->accompanyingPeriodParticipations as $participation)
{
$endDate = $participation->getEndDate();
if ($endDate === null || $endDate > $currentDate){
$currentAccompanyingPeriods[] = $participation->getAccompanyingPeriod();
}
}
return $currentAccompanyingPeriods;
}
/**
* Get AccompanyingPeriodParticipations Collection
*