mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Do not dispatch PersonMoveEvent if moving to a position not sharing
household
This commit is contained in:
@@ -61,8 +61,6 @@ class MembersEditor
|
||||
throw new LogicException('You must define a household first');
|
||||
}
|
||||
|
||||
$event = new PersonAddressMoveEvent($person);
|
||||
|
||||
$membership = (new HouseholdMember())
|
||||
->setStartDate($date)
|
||||
->setPerson($person)
|
||||
@@ -70,9 +68,13 @@ class MembersEditor
|
||||
->setHolder($holder)
|
||||
->setComment($comment);
|
||||
$this->household->addMember($membership);
|
||||
$event->setNextMembership($membership);
|
||||
|
||||
if ($position->getShareHousehold()) {
|
||||
// launch event only if moving to a "share household" position
|
||||
$event = new PersonAddressMoveEvent($person);
|
||||
$event->setNextMembership($membership);
|
||||
$this->events[] = $event;
|
||||
|
||||
foreach ($person->getHouseholdParticipationsShareHousehold() as $participation) {
|
||||
if ($participation === $membership) {
|
||||
continue;
|
||||
@@ -108,7 +110,6 @@ class MembersEditor
|
||||
|
||||
$this->membershipsAffected[] = $membership;
|
||||
$this->persistables[] = $membership;
|
||||
$this->events[] = $event;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
Reference in New Issue
Block a user