mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
WIP continue editor
This commit is contained in:
@@ -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', [
|
||||
|
Reference in New Issue
Block a user