mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
Add context for household member editor form:
* add context for accompanying period, if indicated in a query parameter; * expand automatically household suggestion, if indicated in a query parameter
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace Chill\PersonBundle\Controller;
|
||||
|
||||
use Chill\PersonBundle\Entity\Household\Position;
|
||||
use Chill\PersonBundle\Repository\AccompanyingPeriodRepository;
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
@@ -25,11 +26,17 @@ class HouseholdMemberController extends ApiController
|
||||
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
private AccompanyingPeriodRepository $periodRepository;
|
||||
|
||||
public function __construct(UrlGeneratorInterface $generator, TranslatorInterface $translator)
|
||||
public function __construct(
|
||||
UrlGeneratorInterface $generator,
|
||||
TranslatorInterface $translator,
|
||||
AccompanyingPeriodRepository $periodRepository
|
||||
)
|
||||
{
|
||||
$this->generator = $generator;
|
||||
$this->translator = $translator;
|
||||
$this->periodRepository = $periodRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,8 +151,23 @@ class HouseholdMemberController extends ApiController
|
||||
'allowLeaveWithoutHousehold' => $allowLeaveWithoutHousehold ?? $request->query->has('allow_leave_without_household'),
|
||||
];
|
||||
|
||||
// context
|
||||
if ($request->query->has('accompanying_period_id')) {
|
||||
$period = $this->periodRepository->find(
|
||||
$request->query->getInt('accompanying_period_id')
|
||||
);
|
||||
|
||||
if ($period === null) {
|
||||
throw $this->createNotFoundException('period not found');
|
||||
}
|
||||
|
||||
// TODO add acl on accompanying Course
|
||||
}
|
||||
|
||||
return $this->render('@ChillPerson/Household/members_editor.html.twig', [
|
||||
'data' => $data
|
||||
'data' => $data,
|
||||
'expandSuggestions' => (int) $request->query->getBoolean('expand_suggestions', false),
|
||||
'accompanyingCourse' => $period ?? null,
|
||||
]);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user