WIP continue editor

This commit is contained in:
2021-06-03 18:11:05 +02:00
parent c6949490a4
commit d9a3e117b2
7 changed files with 274 additions and 32 deletions

View File

@@ -5,6 +5,7 @@ namespace Chill\PersonBundle\Controller;
use Chill\PersonBundle\Entity\Household\Position;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\Household\Household;
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -57,6 +58,8 @@ class HouseholdMemberController extends ApiController
*/
public function editor(Request $request)
{
$em = $this->getDoctrine()->getManager();
if ($request->query->has('persons')) {
$ids = $request->query->get('persons', []);
@@ -65,8 +68,7 @@ class HouseholdMemberController extends ApiController
"is not an array or empty");
}
$persons = $this->getDoctrine()->getManager()
->getRepository(Person::class)
$persons = $em->getRepository(Person::class)
->findById($ids)
;
@@ -77,6 +79,20 @@ class HouseholdMemberController extends ApiController
}
}
if ($householdId = $request->query->get('household', false)) {
$household = $em->getRepository(Household::class)
->find($householdId)
;
$allowHouseholdCreate = false;
$allowHouseholdSearch = false;
$allowLeaveWithoutHousehold = false;
if (NULL === $household) {
throw $this->createNotFoundException('household not found');
}
// TODO ACL on household
}
$positions = $this->getDoctrine()->getManager()
->getRepository(Position::class)
->findAll()
@@ -84,10 +100,14 @@ class HouseholdMemberController extends ApiController
$data = [
'persons' => $persons ?? false ?
$this->getSerializer()->normalize($persons, 'json', [ 'groups' => [ 'read' ]]): [],
'household' => null,
$this->getSerializer()->normalize($persons, 'json', [ 'groups' => [ 'read' ]]) : [],
'household' => $household ?? false ?
$this->getSerializer()->normalize($household, 'json', [ 'groups' => [ 'read' ]]) : null,
'positions' =>
$this->getSerializer()->normalize($positions, 'json', [ 'groups' => [ 'read' ]])
$this->getSerializer()->normalize($positions, 'json', [ 'groups' => [ 'read' ]]),
'allowHouseholdCreate' => $allowHouseholdCreate ?? true,
'allowHouseholdSearch' => $allowHouseholdSearch ?? true,
'allowLeaveWithoutHousehold' => $allowLeaveWithoutHousehold ?? $request->query->has('allow_leave_without_household'),
];
return $this->render('@ChillPerson/Household/members_editor.html.twig', [