rewrite methods for participation

This commit is contained in:
2021-05-10 13:21:28 +02:00
parent 8002725c87
commit f3a8552829
2 changed files with 49 additions and 8 deletions

View File

@@ -384,9 +384,9 @@ class AccompanyingPeriod
}
/**
* Add Person
* Open a new participation for a person
*/
public function addPerson(Person $person = null): AccompanyingPeriodParticipation
public function createParticipationFor(Person $person): AccompanyingPeriodParticipation
{
$participation = new AccompanyingPeriodParticipation($this, $person);
$this->participations[] = $participation;
@@ -394,10 +394,24 @@ class AccompanyingPeriod
return $participation;
}
public function addPerson(Person $person = null): self
{
if (NULL !== $person) {
$this->createParticipationFor($person);
}
return $this;
}
/**
* Remove Person
* Close a participation for a person
*
* Search for the person's participation and set the end date at
* 'now'.
*
* @return void
*/
public function removePerson(Person $person): ?AccompanyingPeriodParticipation
public function closeParticipationFor($person): ?AccompanyingPeriodParticipation
{
$participation = $this->getOpenParticipationContainsPerson($person);
@@ -407,6 +421,17 @@ class AccompanyingPeriod
return $participation;
}
/**
* Remove Person
*/
public function removePerson(Person $person): self
{
$this->closeParticipationFor($person);
return $this;
}
public function getClosingMotive(): ?ClosingMotive