person: can reopen an accompanying course

This commit is contained in:
nobohan
2022-01-19 21:46:40 +01:00
parent 9d6afc4bb2
commit d4efe81dbb
6 changed files with 96 additions and 0 deletions

View File

@@ -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,
]);
}
}