mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
method added to get current accompanying periods + api adjusted
This commit is contained in:
parent
cab7cc4150
commit
f064e8f307
@ -197,7 +197,7 @@ $workflow = $this->registry->get($accompanyingPeriod);
|
||||
* @ParamConverter("person", options={"id" = "person_id"})
|
||||
*/
|
||||
public function getAccompanyingPeriodsByPerson(Person $person){
|
||||
$accompanyingPeriods = $person->getAccompanyingPeriods();
|
||||
$accompanyingPeriods = $person->getCurrentAccompanyingPeriods();
|
||||
$accompanyingPeriodsChecked = array_filter($accompanyingPeriods,
|
||||
function(AccompanyingPeriod $period){
|
||||
return $this->isGranted(AccompanyingPeriodVoter::SEE, $period);
|
||||
|
@ -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
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user