cs: Fix AccompanyingCourseController.

This commit is contained in:
Pol Dellaiera 2021-11-23 15:25:12 +01:00
parent cd55e80275
commit 0248dddc9e
No known key found for this signature in database
GPG Key ID: D476DFE9C67467CA

View File

@ -43,10 +43,10 @@ class AccompanyingCourseController extends Controller
private Registry $registry; private Registry $registry;
private AccompanyingPeriodWorkRepository $workRepository;
private TranslatorInterface $translator; private TranslatorInterface $translator;
private AccompanyingPeriodWorkRepository $workRepository;
public function __construct( public function __construct(
SerializerInterface $serializer, SerializerInterface $serializer,
EventDispatcherInterface $dispatcher, EventDispatcherInterface $dispatcher,
@ -72,7 +72,7 @@ class AccompanyingCourseController extends Controller
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::EDIT, $accompanyingCourse); $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::EDIT, $accompanyingCourse);
$form = $this->createForm(AccompanyingCourseType::class, $accompanyingCourse, [ $form = $this->createForm(AccompanyingCourseType::class, $accompanyingCourse, [
'validation_groups' => [AccompanyingPeriod::STEP_CLOSED] 'validation_groups' => [AccompanyingPeriod::STEP_CLOSED],
]); ]);
$form->handleRequest($request); $form->handleRequest($request);
@ -83,7 +83,6 @@ class AccompanyingCourseController extends Controller
$workflow = $this->registry->get($accompanyingCourse); $workflow = $this->registry->get($accompanyingCourse);
if ($workflow->can($accompanyingCourse, 'close')) { if ($workflow->can($accompanyingCourse, 'close')) {
$workflow->apply($accompanyingCourse, 'close'); $workflow->apply($accompanyingCourse, 'close');
$em->flush(); $em->flush();
@ -91,7 +90,7 @@ class AccompanyingCourseController extends Controller
return $this->redirectToRoute('chill_person_accompanying_course_index', [ return $this->redirectToRoute('chill_person_accompanying_course_index', [
'accompanying_period_id' => $accompanyingCourse->getId(), 'accompanying_period_id' => $accompanyingCourse->getId(),
]); ]);
} else { }
/** @var ConstraintViolationListInterface $errors */ /** @var ConstraintViolationListInterface $errors */
$errors = $this->validator->validate($accompanyingCourse, null, [$accompanyingCourse::STEP_CLOSED]); $errors = $this->validator->validate($accompanyingCourse, null, [$accompanyingCourse::STEP_CLOSED]);
$this->addFlash('error', $this->translator->trans('It is not possible to close this course')); $this->addFlash('error', $this->translator->trans('It is not possible to close this course'));
@ -101,7 +100,6 @@ class AccompanyingCourseController extends Controller
$this->addFlash('error', $e->getMessage()); $this->addFlash('error', $e->getMessage());
} }
} }
}
return $this->render('@ChillPerson/AccompanyingCourse/close.html.twig', [ return $this->render('@ChillPerson/AccompanyingCourse/close.html.twig', [
'form' => $form->createView(), 'form' => $form->createView(),