mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 22:35:01 +00:00
Initial setup of controller and templates
This commit is contained in:
@@ -115,46 +115,29 @@ class CalendarController extends AbstractController
|
||||
}
|
||||
|
||||
#[Route(path: '/{_locale}/calendar/calendar/{id}/cancel', name: 'chill_calendar_calendar_cancel')]
|
||||
|
||||
public function cancelAction(Calendar $calendar, Request $request): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(CalendarVoter::EDIT, $calendar);
|
||||
|
||||
[$person, $accompanyingPeriod] = [$calendar->getPerson(), $calendar->getAccompanyingPeriod()];
|
||||
|
||||
$form = $this->createForm(CancelType::class, $calendar);
|
||||
$form->add('submit', SubmitType::class);
|
||||
|
||||
if ($accompanyingPeriod instanceof AccompanyingPeriod) {
|
||||
$view = '@ChillCalendar/Calendar/cancelCalendarByAccompanyingCourse.html.twig';
|
||||
$redirectRoute = $this->generateUrl('chill_calendar_calendar_list_by_period', ['id' => $accompanyingPeriod->getId()]);
|
||||
// $redirectRoute = $this->generateUrl('chill_calendar_calendar_list_by_period', ['id' => $accompanyingPeriod->getId()]);
|
||||
} elseif ($person instanceof Person) {
|
||||
$view = '@ChillCalendar/Calendar/cancelCalendarByPerson.html.twig';
|
||||
$redirectRoute = $this->generateUrl('chill_calendar_calendar_list_by_person', ['id' => $person->getId()]);
|
||||
// $redirectRoute = $this->generateUrl('chill_calendar_calendar_list_by_person', ['id' => $person->getId()]);
|
||||
} else {
|
||||
throw new \RuntimeException('nor person or accompanying period');
|
||||
}
|
||||
|
||||
$form->handleRequest($request);
|
||||
// Cancellation form
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
|
||||
$this->logger->notice('A calendar event has been cancelled', [
|
||||
'by_user' => $this->getUser()->getUsername(),
|
||||
'calendar_id' => $calendar->getId(),
|
||||
]);
|
||||
|
||||
$calendar->setStatus($calendar::STATUS_CANCELED);
|
||||
$calendar->setSmsStatus($calendar::SMS_CANCEL_PENDING);
|
||||
$this->em->flush();
|
||||
|
||||
$this->addFlash('success', $this->translator->trans('chill_calendar.calendar_canceled'));
|
||||
|
||||
return new RedirectResponse($redirectRoute);
|
||||
}
|
||||
|
||||
return $this->render($view, [
|
||||
'calendar' => $calendar,
|
||||
'form' => $form->createView(),
|
||||
// 'delete_form' => $form->createView(),
|
||||
'accompanyingCourse' => $accompanyingPeriod,
|
||||
'person' => $person,
|
||||
]);
|
||||
|
Reference in New Issue
Block a user