mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
Merge remote-tracking branch 'origin/master' into features/activity-form
This commit is contained in:
@@ -369,13 +369,9 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
public function setRemark(string $remark): self
|
||||
public function setRemark(string $remark = null): self
|
||||
{
|
||||
if ($remark === null) {
|
||||
$remark = '';
|
||||
}
|
||||
|
||||
$this->remark = $remark;
|
||||
$this->remark = (string) $remark;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -447,12 +443,13 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
||||
*/
|
||||
public function getParticipationsContainsPerson(Person $person): Collection
|
||||
{
|
||||
return $this->getParticipations($person)->filter(
|
||||
function(AccompanyingPeriodParticipation $participation) use ($person) {
|
||||
if ($person === $participation->getPerson()) {
|
||||
return $participation;
|
||||
return $this
|
||||
->getParticipations()
|
||||
->filter(
|
||||
static function(AccompanyingPeriodParticipation $participation) use ($person): bool {
|
||||
return $person === $participation->getPerson();
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -462,12 +459,13 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
||||
*/
|
||||
public function getOpenParticipationContainsPerson(Person $person): ?AccompanyingPeriodParticipation
|
||||
{
|
||||
$collection = $this->getParticipationsContainsPerson($person)->filter(
|
||||
function(AccompanyingPeriodParticipation $participation) use ($person) {
|
||||
if (NULL === $participation->getEndDate()) {
|
||||
return $participation;
|
||||
$collection = $this
|
||||
->getParticipationsContainsPerson($person)
|
||||
->filter(
|
||||
static function(AccompanyingPeriodParticipation $participation): bool {
|
||||
return null === $participation->getEndDate();
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
return $collection->count() > 0 ? $collection->first() : NULL;
|
||||
}
|
||||
@@ -557,15 +555,16 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
$participation = $this->getParticipationsContainsPerson($person);
|
||||
if (!null === $participation)
|
||||
$participation = $this->getOpenParticipationContainsPerson($person);
|
||||
|
||||
if (null === $participation)
|
||||
{
|
||||
$person = $participation->getPerson();
|
||||
$periods = $person->getAccompanyingPeriodsOrdered();
|
||||
return end($periods) === $this;
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
$periods = $participation->getPerson()->getAccompanyingPeriodsOrdered();
|
||||
|
||||
return end($periods) === $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -863,14 +862,18 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
||||
|
||||
/**
|
||||
* Get a list of all persons which are participating to this course
|
||||
*
|
||||
* @psalm-return Collection<int, Person>
|
||||
*/
|
||||
public function getPersons(): Collection
|
||||
{
|
||||
return $this->participations->map(
|
||||
function(AccompanyingPeriodParticipation $participation) {
|
||||
return $participation->getPerson();
|
||||
}
|
||||
);
|
||||
return $this
|
||||
->participations
|
||||
->map(
|
||||
static function(AccompanyingPeriodParticipation $participation): Person {
|
||||
return $participation->getPerson();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function setCreatedAt(\DateTimeInterface $datetime): self
|
||||
|
Reference in New Issue
Block a user