mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
Merge branch 'features/household-members-list' into features/household-editor
This commit is contained in:
@@ -6,17 +6,32 @@ use Chill\PersonBundle\Entity\Household\Position;
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Chill\PersonBundle\Form\HouseholdMemberType;
|
||||
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
||||
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Serializer\Exception;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
use Chill\PersonBundle\Household\MembersEditor;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
|
||||
class HouseholdMemberController extends ApiController
|
||||
{
|
||||
private UrlGeneratorInterface $generator;
|
||||
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
|
||||
public function __construct(UrlGeneratorInterface $generator, TranslatorInterface $translator)
|
||||
{
|
||||
$this->generator = $generator;
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(
|
||||
* "/api/1.0/person/household/members/move.{_format}",
|
||||
@@ -153,4 +168,39 @@ class HouseholdMemberController extends ApiController
|
||||
'data' => $data
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(
|
||||
* "/api/1.0/person/household/member/{id}/edit",
|
||||
* name="chill_person_household_member_edit"
|
||||
* )
|
||||
*/
|
||||
public function editMembership(Request $request, HouseholdMember $member): Response
|
||||
{
|
||||
// TODO ACL
|
||||
|
||||
$form = $this->createForm(HouseholdMemberType::class, $member);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
|
||||
$this->addFlash('success', $this->translator
|
||||
->trans('household.successfully saved member'))
|
||||
;
|
||||
|
||||
return $this->redirect(
|
||||
$request->get('returnPath', null) ??
|
||||
$this->generator->generate('chill_person_household_members', [ 'household_id' =>
|
||||
$member->getHousehold()->getId() ])
|
||||
);
|
||||
}
|
||||
|
||||
return $this->render('@ChillPerson/Household/Member/edit.html.twig', [
|
||||
'household' => $member->getHousehold(),
|
||||
'member' => $member,
|
||||
'form' => $form->createView()
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user