handle event PersonMoveEvent on Period

This commit is contained in:
2022-02-15 23:52:15 +01:00
parent 1658fee090
commit 0a4913f341
8 changed files with 495 additions and 63 deletions

View File

@@ -217,7 +217,7 @@ class AccompanyingPeriod implements
/**
* @ORM\OneToMany(targetEntity=AccompanyingPeriodLocationHistory::class,
* mappedBy="period", cascade="{"persist", "remove""}, orphanRemoval=true)
* mappedBy="period", cascade={"persist", "remove"}, orphanRemoval=true)
*/
private Collection $locationHistories;
@@ -709,6 +709,17 @@ class AccompanyingPeriod implements
return $this->job;
}
public function getLastLocationHistory(): ?AccompanyingPeriodLocationHistory
{
foreach ($this->getLocationHistories() as $locationHistory) {
if (null === $locationHistory->getEndDate()) {
return $locationHistory;
}
}
return null;
}
/**
* Get the location, taking precedence into account.
*
@@ -723,6 +734,9 @@ class AccompanyingPeriod implements
return $this->getAddressLocation();
}
/**
* @return Collection|AccompanyingPeriodLocationHistory[]
*/
public function getLocationHistories(): Collection
{
return $this->locationHistories;

View File

@@ -66,6 +66,7 @@ class AccompanyingPeriodParticipation
$this->startDate = new DateTime('now');
$this->accompanyingPeriod = $accompanyingPeriod;
$this->person = $person;
$person->getAccompanyingPeriodParticipations()->add($this);
}
public function getAccompanyingPeriod(): ?AccompanyingPeriod