diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php index da361abda..996c195cc 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php @@ -54,6 +54,11 @@ class HouseholdMemberController extends ApiController // $em = $this->getDoctrine()->getManager(); + // if new household, persist it + if (FALSE === $em->contains($editor->getHousehold())) { + $em->persist($editor->getHousehold()); + } + foreach ($editor->getPersistable() as $el) { $em->persist($el); } diff --git a/src/Bundle/ChillPersonBundle/Household/MembersEditor.php b/src/Bundle/ChillPersonBundle/Household/MembersEditor.php index 527404c75..970010288 100644 --- a/src/Bundle/ChillPersonBundle/Household/MembersEditor.php +++ b/src/Bundle/ChillPersonBundle/Household/MembersEditor.php @@ -35,9 +35,9 @@ class MembersEditor ->setPerson($person) ->setPosition($position) ->setHolder($holder) - ->setHousehold($this->household) ->setComment($comment) ; + $this->household->addMember($membership); if ($position->getShareHousehold()) { foreach ($person->getHouseholdParticipations() as $participation) { diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/MembersEditorNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/MembersEditorNormalizer.php index 603c1a9e5..12fe4ab5c 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/MembersEditorNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/MembersEditorNormalizer.php @@ -34,7 +34,7 @@ class MembersEditorNormalizer implements DenormalizerInterface, DenormalizerAwar $editor = $this->factory->createEditor($household); - if (NULL == $data['concerned'] ?? [] + if (NULL == $data['concerned'] ?? NULL && FALSE === ยท\is_array('concerned')) { throw new Exception\UnexpectedValueException("The schema does not have any key 'concerned'"); }