From 24eb220e906dace0bbebc31ad95e28b4c18eec9c Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 14 Jan 2025 13:31:29 +0100 Subject: [PATCH] Pipeline corrections --- .../Controller/CalendarController.php | 46 ------------------- .../ChillCalendarBundle/Form/CancelType.php | 8 +--- 2 files changed, 2 insertions(+), 52 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index b2a9e978f..0ec79fd68 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -37,7 +37,6 @@ use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Form; -use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; @@ -116,51 +115,6 @@ class CalendarController extends AbstractController } #[Route(path: '/{_locale}/calendar/calendar/{id}/cancel', name: 'chill_calendar_calendar_cancel')] - public function cancelAction(Calendar $calendar, Request $request): Response - { - // Deal with sms being sent or not - // Communicate cancellation with the remote calendar. - - $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()]); - } elseif ($person instanceof Person) { - $view = '@ChillCalendar/Calendar/cancelCalendarByPerson.html.twig'; - $redirectRoute = $this->generateUrl('chill_calendar_calendar_list_by_person', ['id' => $person->getId()]); - } else { - throw new \RuntimeException('nor person or accompanying period'); - } - - $form->handleRequest($request); - - if ($form->isSubmitted() && $form->isValid()) { - - $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(), - 'accompanyingCourse' => $accompanyingPeriod, - 'person' => $person, - ]); - } - - #[Route(path: '/{_locale}/calendar/calendar/{id}/cancel', name: 'chill_calendar_calendar_cancel')] - public function cancelAction(Calendar $calendar, Request $request): Response { // Deal with sms being sent or not diff --git a/src/Bundle/ChillCalendarBundle/Form/CancelType.php b/src/Bundle/ChillCalendarBundle/Form/CancelType.php index 6b63344f2..ad41a6105 100644 --- a/src/Bundle/ChillCalendarBundle/Form/CancelType.php +++ b/src/Bundle/ChillCalendarBundle/Form/CancelType.php @@ -21,18 +21,14 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class CancelType extends AbstractType { - public function __construct(private readonly TranslatableStringHelperInterface $translatableStringHelper) - { - } + public function __construct(private readonly TranslatableStringHelperInterface $translatableStringHelper) {} public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('cancelReason', EntityType::class, [ 'class' => CancelReason::class, 'required' => true, - 'choice_label' => function (CancelReason $cancelReason) { - return $this->translatableStringHelper->localize($cancelReason->getName()); - }, + 'choice_label' => fn (CancelReason $cancelReason) => $this->translatableStringHelper->localize($cancelReason->getName()), ]); }