mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch 'fix-getParticipationsContainsPerson' into 'master'
Fix `::getParticipationsContainsPerson`. See merge request Chill-Projet/chill-bundles!50
This commit is contained in:
commit
126ffc55bf
@ -447,12 +447,13 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
*/
|
*/
|
||||||
public function getParticipationsContainsPerson(Person $person): Collection
|
public function getParticipationsContainsPerson(Person $person): Collection
|
||||||
{
|
{
|
||||||
return $this->getParticipations($person)->filter(
|
return $this
|
||||||
function(AccompanyingPeriodParticipation $participation) use ($person) {
|
->getParticipations()
|
||||||
if ($person === $participation->getPerson()) {
|
->filter(
|
||||||
return $participation;
|
static function(AccompanyingPeriodParticipation $participation) use ($person): bool {
|
||||||
|
return $person === $participation->getPerson();
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -462,12 +463,13 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
*/
|
*/
|
||||||
public function getOpenParticipationContainsPerson(Person $person): ?AccompanyingPeriodParticipation
|
public function getOpenParticipationContainsPerson(Person $person): ?AccompanyingPeriodParticipation
|
||||||
{
|
{
|
||||||
$collection = $this->getParticipationsContainsPerson($person)->filter(
|
$collection = $this
|
||||||
function(AccompanyingPeriodParticipation $participation) use ($person) {
|
->getParticipationsContainsPerson($person)
|
||||||
if (NULL === $participation->getEndDate()) {
|
->filter(
|
||||||
return $participation;
|
static function(AccompanyingPeriodParticipation $participation): bool {
|
||||||
|
return null === $participation->getEndDate();
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
|
|
||||||
return $collection->count() > 0 ? $collection->first() : NULL;
|
return $collection->count() > 0 ? $collection->first() : NULL;
|
||||||
}
|
}
|
||||||
@ -557,15 +559,16 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$participation = $this->getParticipationsContainsPerson($person);
|
$participation = $this->getOpenParticipationContainsPerson($person);
|
||||||
if (!null === $participation)
|
|
||||||
|
if (null === $participation)
|
||||||
{
|
{
|
||||||
$person = $participation->getPerson();
|
return false;
|
||||||
$periods = $person->getAccompanyingPeriodsOrdered();
|
|
||||||
return end($periods) === $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
$periods = $participation->getPerson()->getAccompanyingPeriodsOrdered();
|
||||||
|
|
||||||
|
return end($periods) === $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -825,11 +828,15 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of all persons which are participating to this course
|
* Get a list of all persons which are participating to this course
|
||||||
|
*
|
||||||
|
* @psalm-return Collection<int, Person>
|
||||||
*/
|
*/
|
||||||
public function getPersons(): Collection
|
public function getPersons(): Collection
|
||||||
{
|
{
|
||||||
return $this->participations->map(
|
return $this
|
||||||
function(AccompanyingPeriodParticipation $participation) {
|
->participations
|
||||||
|
->map(
|
||||||
|
static function(AccompanyingPeriodParticipation $participation): Person {
|
||||||
return $participation->getPerson();
|
return $participation->getPerson();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user