period: fix method hasPreviousUser and create method isChangedUser, and use it in Notification

This commit is contained in:
2022-04-22 12:12:30 +02:00
parent f7d9551dc1
commit 2d9af8f8c0
3 changed files with 42 additions and 2 deletions

View File

@@ -361,6 +361,8 @@ class AccompanyingPeriod implements
*/
private Collection $userHistories;
private bool $userIsChanged = false;
/**
* Temporary field, which is filled when the user is changed.
*
@@ -975,7 +977,12 @@ class AccompanyingPeriod implements
public function hasPreviousUser(): bool
{
return $this->user !== $this->userPrevious;
return null !== $this->userPrevious;
}
public function isChangedUser(): bool
{
return $this->userIsChanged && $this->user !== $this->userPrevious;
}
/**
@@ -1103,6 +1110,14 @@ class AccompanyingPeriod implements
$this->setStep(AccompanyingPeriod::STEP_CONFIRMED);
}
public function resetPreviousUser(): self
{
$this->userPrevious = null;
$this->userIsChanged = false;
return $this;
}
/**
* @Groups({"write"})
*/
@@ -1329,6 +1344,7 @@ class AccompanyingPeriod implements
{
if ($this->user !== $user) {
$this->userPrevious = $this->user;
$this->userIsChanged = true;
foreach ($this->userHistories as $history) {
if (null === $history->getEndDate()) {