add groups on household serialization

This commit is contained in:
2021-06-02 21:44:49 +02:00
parent 261acdfd24
commit e9caa7b4b8
4 changed files with 67 additions and 10 deletions

View File

@@ -9,6 +9,7 @@ use Symfony\Component\Serializer\Exception;
use Symfony\Component\Routing\Annotation\Route;
use Chill\MainBundle\CRUD\Controller\ApiController;
use Chill\PersonBundle\Household\MembersEditor;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
class HouseholdMemberController extends ApiController
{
@@ -27,24 +28,20 @@ class HouseholdMemberController extends ApiController
} catch (Exception\InvalidArgumentException | Exception\UnexpectedValueException $e) {
throw new BadRequestException("Deserialization error: {$e->getMessage()}", 45896, $e);
}
dump($editor);
// TODO ACL
//
// TODO validation
//
$em = $this->getDoctrine()->getManager();
// to ensure closing membership before creating one, we must manually open a transaction
$em->beginTransaction();
foreach ($editor->getPersistable() as $el) {
$em->persist($el);
}
$em->flush();
$em->commit();
return $this->json($editor->getHousehold(), Response::HTTP_OK, ["groups" => ["read"]]);
return $this->json($editor->getHousehold(), Response::HTTP_OK, [], [
"groups" => ["read"],
]);
}
}