mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
controller action to create parcours from within household + link added in template
This commit is contained in:
@@ -13,6 +13,7 @@ namespace Chill\PersonBundle\Controller;
|
||||
|
||||
use Chill\ActivityBundle\Entity\Activity;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Form\AccompanyingCourseType;
|
||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
|
||||
@@ -279,6 +280,40 @@ class AccompanyingCourseController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/person/household/parcours/new", name="chill_household_accompanying_course_new")
|
||||
*/
|
||||
public function newHouseholdParcoursAction(Request $request): Response
|
||||
{
|
||||
$period = new AccompanyingPeriod();
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
if ($request->query->has('household_id')) {
|
||||
$householdId = $request->query->get('household_id');
|
||||
|
||||
$household = $em->getRepository(Household::class)->find($householdId);
|
||||
$members = $household->getCurrentMembers();
|
||||
|
||||
if (null !== $members) {
|
||||
foreach ($members as $m) {
|
||||
$period->addPerson($m->getPerson());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$userLocation = $this->getUser()->getCurrentLocation();
|
||||
$period->setAdministrativeLocation($userLocation);
|
||||
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::CREATE, $period);
|
||||
|
||||
$em->persist($period);
|
||||
$em->flush();
|
||||
|
||||
return $this->redirectToRoute('chill_person_accompanying_course_edit', [
|
||||
'accompanying_period_id' => $period->getId(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/parcours/{accompanying_period_id}/open", name="chill_person_accompanying_course_reopen")
|
||||
* @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
|
||||
|
Reference in New Issue
Block a user