mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 23:23:51 +00:00
person: can reopen an accompanying course
This commit is contained in:
@@ -275,4 +275,60 @@ class AccompanyingCourseController extends Controller
|
||||
'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"})
|
||||
*/
|
||||
public function reOpenAction(AccompanyingPeriod $accompanyingCourse, Request $request): Response
|
||||
{
|
||||
//$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::EDIT, $accompanyingCourse);
|
||||
|
||||
// $form = $this->createForm(AccompanyingCourseType::class, $accompanyingCourse, [
|
||||
// 'validation_groups' => [AccompanyingPeriod::STEP_CLOSED],
|
||||
// ]);
|
||||
|
||||
$form = $this->createFormBuilder([])->getForm();
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$accompanyingCourse->reOpen();
|
||||
$em->flush();
|
||||
|
||||
return $this->redirectToRoute('chill_person_accompanying_course_index', [
|
||||
'accompanying_period_id' => $accompanyingCourse->getId(),
|
||||
]);
|
||||
|
||||
//TODO: delete motif de cloture and date de cloture (NULL)
|
||||
//TODO: which redirection?
|
||||
//TODO workflow stuff?
|
||||
//TODO: error handling
|
||||
// $workflow = $this->registry->get($accompanyingCourse);
|
||||
|
||||
// if ($workflow->can($accompanyingCourse, 'close')) {
|
||||
// $workflow->apply($accompanyingCourse, 'close');
|
||||
|
||||
// $em->flush();
|
||||
|
||||
// return $this->redirectToRoute('chill_person_accompanying_course_index', [
|
||||
// 'accompanying_period_id' => $accompanyingCourse->getId(),
|
||||
// ]);
|
||||
// }
|
||||
// /** @var ConstraintViolationListInterface $errors */
|
||||
// $errors = $this->validator->validate($accompanyingCourse, null, [$accompanyingCourse::STEP_CLOSED]);
|
||||
// $this->addFlash('error', $this->translator->trans('It is not possible to close this course'));
|
||||
|
||||
// foreach ($errors as $e) {
|
||||
// /** @var ConstraintViolationInterface $e */
|
||||
// $this->addFlash('error', $e->getMessage());
|
||||
// }
|
||||
}
|
||||
|
||||
return $this->render('@ChillPerson/AccompanyingCourse/reopen.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
'accompanyingCourse' => $accompanyingCourse,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user