Add translation, make reason required, and change template for form

This commit is contained in:
2024-12-17 16:04:05 +01:00
parent 5efbec9b42
commit 57bc61b218
4 changed files with 22 additions and 8 deletions

View File

@@ -119,6 +119,11 @@ class CalendarController extends AbstractController
public function cancelAction(Calendar $calendar, Request $request): Response
{
// Add voter
// Deal with sms being sent or not
// Communicate cancellation with the remote calendar.
$this->denyAccessUnlessGranted(CalendarVoter::EDIT, $calendar);
[$person, $accompanyingPeriod] = [$calendar->getPerson(), $calendar->getAccompanyingPeriod()];
@@ -139,10 +144,11 @@ class CalendarController extends AbstractController
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->em->persist($calendar);
$calendar->setStatus($calendar::STATUS_CANCELED);
$this->em->flush();
$this->addFlash('success', $this->translator->trans('calender.calendar item has been canceled!'));
$this->addFlash('success', $this->translator->trans('chill_calendar.calendar_canceled'));
return new RedirectResponse($redirectRoute);
}