PersonMoveEventSubscriber: handle case when the move is before the last

locationHistory, but the move affects "now"
This commit is contained in:
2022-02-19 10:27:44 +01:00
parent 104af6d9b5
commit 8675bb65c1
4 changed files with 58 additions and 12 deletions

View File

@@ -61,8 +61,18 @@ class PersonMoveEventSubscriber implements EventSubscriberInterface
continue;
}
if ($period->getPersonLocation() === $person
&& $event->getMoveDate() >= $period->getLastLocationHistory()->getStartDate()
$now = new \DateTimeImmutable('now');
if (
$period->getPersonLocation() === $person
&&
(
$event->getMoveDate() >= $period->getLastLocationHistory()->getStartDate()
|| (
$event->getNextAddress()->getValidFrom() < $now
&& (null === $event->getNextAddress()->getValidTo() || $event->getNextAddress()->getValidTo() > $now)
)
)
&& null !== $period->getUser()
&& $period->getUser() !== $this->security->getUser()
) {