From fc3eda7b761063d2cd768f0bc994b8bd45cd9ffa Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 12 Dec 2024 15:40:41 +0100 Subject: [PATCH 01/18] Initial setup of controller and templates --- .../Controller/CalendarController.php | 29 +++++++++++++++++++ .../Resources/views/Calendar/_list.html.twig | 4 +++ ...ncelCalendarByAccompanyingCourse.html.twig | 5 ++++ .../Calendar/cancelCalendarByPerson.html.twig | 5 ++++ .../translations/messages.fr.yml | 3 +- 5 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByAccompanyingCourse.html.twig create mode 100644 src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByPerson.html.twig diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index 94db03b1f..4793dbe1b 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -111,6 +111,35 @@ 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()]; + + 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'); + } + + // Cancellation form + + + return $this->render($view, [ + 'calendar' => $calendar, +// 'delete_form' => $form->createView(), + 'accompanyingCourse' => $accompanyingPeriod, + 'person' => $person, + ]); + } + /** * Edit a calendar item. */ diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig index cff5c00cc..6b11256f8 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig @@ -219,6 +219,10 @@ class="btn btn-update "> {% endif %} +
  • + {{ 'cancel'|trans }} +
  • {% if is_granted('CHILL_CALENDAR_CALENDAR_DELETE', calendar) %}
  • Date: Mon, 16 Dec 2024 19:08:42 +0100 Subject: [PATCH 02/18] Add cancel reason form --- .../Controller/CalendarController.php | 22 +++++++++-- .../ChillCalendarBundle/Form/CancelType.php | 37 +++++++++++++++++++ ...ncelCalendarByAccompanyingCourse.html.twig | 17 +++++++++ .../Calendar/cancelCalendarByPerson.html.twig | 17 +++++++++ 4 files changed, 89 insertions(+), 4 deletions(-) create mode 100644 src/Bundle/ChillCalendarBundle/Form/CancelType.php diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index 4793dbe1b..d036b6b1e 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -13,6 +13,7 @@ namespace Chill\CalendarBundle\Controller; use Chill\CalendarBundle\Entity\Calendar; use Chill\CalendarBundle\Form\CalendarType; +use Chill\CalendarBundle\Form\CancelType; use Chill\CalendarBundle\RemoteCalendar\Connector\RemoteCalendarConnectorInterface; use Chill\CalendarBundle\Repository\CalendarACLAwareRepositoryInterface; use Chill\CalendarBundle\Security\Voter\CalendarVoter; @@ -30,11 +31,13 @@ use Chill\PersonBundle\Repository\PersonRepository; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; use Chill\PersonBundle\Security\Authorization\PersonVoter; use Chill\ThirdPartyBundle\Entity\ThirdParty; +use Doctrine\ORM\EntityManagerInterface; use http\Exception\UnexpectedValueException; 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; @@ -60,6 +63,7 @@ class CalendarController extends AbstractController private readonly UserRepositoryInterface $userRepository, private readonly TranslatorInterface $translator, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry, + private readonly EntityManagerInterface $em, ) {} /** @@ -119,22 +123,32 @@ class CalendarController extends AbstractController [$person, $accompanyingPeriod] = [$calendar->getPerson(), $calendar->getAccompanyingPeriod()]; + $form = $this->createForm(CancelType::class, $calendar); + 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'); } - // Cancellation form + $form->handleRequest($request); + if ($form->isSubmitted() && $form->isValid()) { + $this->em->persist($calendar); + $this->em->flush(); + + $this->addFlash('success', $this->translator->trans('calender.calendar item has been canceled!')); + + return new RedirectResponse($redirectRoute); + } return $this->render($view, [ 'calendar' => $calendar, -// 'delete_form' => $form->createView(), + 'form' => $form->createView(), 'accompanyingCourse' => $accompanyingPeriod, 'person' => $person, ]); diff --git a/src/Bundle/ChillCalendarBundle/Form/CancelType.php b/src/Bundle/ChillCalendarBundle/Form/CancelType.php new file mode 100644 index 000000000..c4f790c7d --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Form/CancelType.php @@ -0,0 +1,37 @@ +add('cancelReason', EntityType::class, array( + 'class' => CancelReason::class, + 'required' => false, + 'choice_label' => function (CancelReason $cancelReason) { + return $this->translatableStringHelper->localize($cancelReason->getName()); + }, + )); + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults([ + 'data_class' => Calendar::class, + + ]); + } +} diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByAccompanyingCourse.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByAccompanyingCourse.html.twig index 19659c627..10841bf9f 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByAccompanyingCourse.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByAccompanyingCourse.html.twig @@ -3,3 +3,20 @@ {% set activeRouteKey = 'chill_calendar_calendar_list' %} {% block title 'chill_calendar.cancel_calendar_item'|trans %} + +{% block content %} + + {{ form(form) }} + + + +{% endblock %} diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByPerson.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByPerson.html.twig index b3db97e0f..867a5b548 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByPerson.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByPerson.html.twig @@ -3,3 +3,20 @@ {% set activeRouteKey = 'chill_calendar_calendar_list' %} {% block title 'chill_calendar.cancel_calendar_item'|trans %} + +{% block content %} + + {{ form_row(form.cancelReason) }} + + + +{% endblock %} From d0d3be9bc1dd862834339b4993e7beb49b4b1311 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 17 Dec 2024 09:35:52 +0100 Subject: [PATCH 03/18] Fix form to submit cancel reason --- .../Controller/CalendarController.php | 1 + .../views/Calendar/cancelCalendarByPerson.html.twig | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index d036b6b1e..65037c005 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -124,6 +124,7 @@ class CalendarController extends AbstractController [$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'; diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByPerson.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByPerson.html.twig index 867a5b548..d6f71cc13 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByPerson.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByPerson.html.twig @@ -6,17 +6,24 @@ {% block content %} + {{ form_start(form) }} + {{ form_row(form.cancelReason) }} + {{ form_end(form) }} + {% endblock %} From cce79de7117aa1204840facfc44c9714e0f0a1ac Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 17 Dec 2024 16:04:05 +0100 Subject: [PATCH 04/18] Add translation, make reason required, and change template for form --- .../Controller/CalendarController.php | 10 ++++++++-- src/Bundle/ChillCalendarBundle/Form/CancelType.php | 6 +++--- .../cancelCalendarByAccompanyingCourse.html.twig | 13 ++++++++++--- .../translations/messages.fr.yml | 1 + 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index 65037c005..293cbeae6 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -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); } diff --git a/src/Bundle/ChillCalendarBundle/Form/CancelType.php b/src/Bundle/ChillCalendarBundle/Form/CancelType.php index c4f790c7d..dc7c4d049 100644 --- a/src/Bundle/ChillCalendarBundle/Form/CancelType.php +++ b/src/Bundle/ChillCalendarBundle/Form/CancelType.php @@ -18,13 +18,13 @@ class CancelType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { - $builder->add('cancelReason', EntityType::class, array( + $builder->add('cancelReason', EntityType::class, [ 'class' => CancelReason::class, - 'required' => false, + 'required' => true, 'choice_label' => function (CancelReason $cancelReason) { return $this->translatableStringHelper->localize($cancelReason->getName()); }, - )); + ]); } public function configureOptions(OptionsResolver $resolver) diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByAccompanyingCourse.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByAccompanyingCourse.html.twig index 10841bf9f..cc378d3cb 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByAccompanyingCourse.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByAccompanyingCourse.html.twig @@ -6,17 +6,24 @@ {% block content %} - {{ form(form) }} + {{ form_start(form) }} + + {{ form_row(form.cancelReason) }} + {{ form_end(form) }} + {% endblock %} diff --git a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml index e35a46d97..527fabb12 100644 --- a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml @@ -45,6 +45,7 @@ crud: chill_calendar: cancel_calendar_item: Annuler rendez-vous + calendar_canceled: Le rendez-vous a été annulé Document: Document d'un rendez-vous form: The main user is mandatory. He will organize the appointment.: L'utilisateur principal est obligatoire. Il est l'organisateur de l'événement. From e76e815c49cebd70d04d35a1b08d1c85b4da1f11 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 18 Dec 2024 13:20:17 +0100 Subject: [PATCH 05/18] Only show cancel button with EDIT permission --- .../Resources/views/Calendar/_list.html.twig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig index 6b11256f8..b77859e83 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig @@ -213,16 +213,18 @@ class="btn btn-show ">
  • {% endif %} + {% if is_granted('CHILL_CALENDAR_CALENDAR_EDIT', calendar) %}
  • - {% endif %}
  • {{ 'cancel'|trans }}
  • + {% endif %} + {% if is_granted('CHILL_CALENDAR_CALENDAR_DELETE', calendar) %}
  • Date: Wed, 18 Dec 2024 13:36:20 +0100 Subject: [PATCH 06/18] Use a different button type --- .../Resources/views/Calendar/_list.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig index b77859e83..46da9a911 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig @@ -221,7 +221,7 @@
  • {{ 'cancel'|trans }} + class="btn btn-remove">{{ 'cancel'|trans }}
  • {% endif %} From 5c85f0478b7df0c4c1b4b05a6673fe0f94b3cc6a Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 18 Dec 2024 13:48:56 +0100 Subject: [PATCH 07/18] Set the sms status to 'canceled' --- .../ChillCalendarBundle/Controller/CalendarController.php | 3 +-- ...t_message_canceled.twig => short_message_canceled.txt.twig} | 0 2 files changed, 1 insertion(+), 2 deletions(-) rename src/Bundle/ChillCalendarBundle/Resources/views/CalendarShortMessage/{short_message_canceled.twig => short_message_canceled.txt.twig} (100%) diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index 293cbeae6..3cd2926e5 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -119,11 +119,9 @@ 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()]; @@ -146,6 +144,7 @@ class CalendarController extends AbstractController 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')); diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/CalendarShortMessage/short_message_canceled.twig b/src/Bundle/ChillCalendarBundle/Resources/views/CalendarShortMessage/short_message_canceled.txt.twig similarity index 100% rename from src/Bundle/ChillCalendarBundle/Resources/views/CalendarShortMessage/short_message_canceled.twig rename to src/Bundle/ChillCalendarBundle/Resources/views/CalendarShortMessage/short_message_canceled.txt.twig From c307aa5a124a21384c1bd6e26a2c3c80d75ea94d Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 12 Dec 2024 15:40:41 +0100 Subject: [PATCH 08/18] Initial setup of controller and templates --- .../Controller/CalendarController.php | 29 +++++++++++++++++++ .../Resources/views/Calendar/_list.html.twig | 4 +++ ...ncelCalendarByAccompanyingCourse.html.twig | 5 ++++ .../Calendar/cancelCalendarByPerson.html.twig | 5 ++++ .../translations/messages.fr.yml | 3 +- 5 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByAccompanyingCourse.html.twig create mode 100644 src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByPerson.html.twig diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index 94db03b1f..4793dbe1b 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -111,6 +111,35 @@ 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()]; + + 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'); + } + + // Cancellation form + + + return $this->render($view, [ + 'calendar' => $calendar, +// 'delete_form' => $form->createView(), + 'accompanyingCourse' => $accompanyingPeriod, + 'person' => $person, + ]); + } + /** * Edit a calendar item. */ diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig index cff5c00cc..6b11256f8 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig @@ -219,6 +219,10 @@ class="btn btn-update "> {% endif %} +
  • + {{ 'cancel'|trans }} +
  • {% if is_granted('CHILL_CALENDAR_CALENDAR_DELETE', calendar) %}
  • Date: Mon, 16 Dec 2024 19:08:42 +0100 Subject: [PATCH 09/18] Add cancel reason form --- .../Controller/CalendarController.php | 22 +++++++++-- .../ChillCalendarBundle/Form/CancelType.php | 37 +++++++++++++++++++ ...ncelCalendarByAccompanyingCourse.html.twig | 17 +++++++++ .../Calendar/cancelCalendarByPerson.html.twig | 17 +++++++++ 4 files changed, 89 insertions(+), 4 deletions(-) create mode 100644 src/Bundle/ChillCalendarBundle/Form/CancelType.php diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index 4793dbe1b..d036b6b1e 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -13,6 +13,7 @@ namespace Chill\CalendarBundle\Controller; use Chill\CalendarBundle\Entity\Calendar; use Chill\CalendarBundle\Form\CalendarType; +use Chill\CalendarBundle\Form\CancelType; use Chill\CalendarBundle\RemoteCalendar\Connector\RemoteCalendarConnectorInterface; use Chill\CalendarBundle\Repository\CalendarACLAwareRepositoryInterface; use Chill\CalendarBundle\Security\Voter\CalendarVoter; @@ -30,11 +31,13 @@ use Chill\PersonBundle\Repository\PersonRepository; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; use Chill\PersonBundle\Security\Authorization\PersonVoter; use Chill\ThirdPartyBundle\Entity\ThirdParty; +use Doctrine\ORM\EntityManagerInterface; use http\Exception\UnexpectedValueException; 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; @@ -60,6 +63,7 @@ class CalendarController extends AbstractController private readonly UserRepositoryInterface $userRepository, private readonly TranslatorInterface $translator, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry, + private readonly EntityManagerInterface $em, ) {} /** @@ -119,22 +123,32 @@ class CalendarController extends AbstractController [$person, $accompanyingPeriod] = [$calendar->getPerson(), $calendar->getAccompanyingPeriod()]; + $form = $this->createForm(CancelType::class, $calendar); + 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'); } - // Cancellation form + $form->handleRequest($request); + if ($form->isSubmitted() && $form->isValid()) { + $this->em->persist($calendar); + $this->em->flush(); + + $this->addFlash('success', $this->translator->trans('calender.calendar item has been canceled!')); + + return new RedirectResponse($redirectRoute); + } return $this->render($view, [ 'calendar' => $calendar, -// 'delete_form' => $form->createView(), + 'form' => $form->createView(), 'accompanyingCourse' => $accompanyingPeriod, 'person' => $person, ]); diff --git a/src/Bundle/ChillCalendarBundle/Form/CancelType.php b/src/Bundle/ChillCalendarBundle/Form/CancelType.php new file mode 100644 index 000000000..c4f790c7d --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Form/CancelType.php @@ -0,0 +1,37 @@ +add('cancelReason', EntityType::class, array( + 'class' => CancelReason::class, + 'required' => false, + 'choice_label' => function (CancelReason $cancelReason) { + return $this->translatableStringHelper->localize($cancelReason->getName()); + }, + )); + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults([ + 'data_class' => Calendar::class, + + ]); + } +} diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByAccompanyingCourse.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByAccompanyingCourse.html.twig index 19659c627..10841bf9f 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByAccompanyingCourse.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByAccompanyingCourse.html.twig @@ -3,3 +3,20 @@ {% set activeRouteKey = 'chill_calendar_calendar_list' %} {% block title 'chill_calendar.cancel_calendar_item'|trans %} + +{% block content %} + + {{ form(form) }} + + + +{% endblock %} diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByPerson.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByPerson.html.twig index b3db97e0f..867a5b548 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByPerson.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByPerson.html.twig @@ -3,3 +3,20 @@ {% set activeRouteKey = 'chill_calendar_calendar_list' %} {% block title 'chill_calendar.cancel_calendar_item'|trans %} + +{% block content %} + + {{ form_row(form.cancelReason) }} + + + +{% endblock %} From c4560b3d89ee440fc06f2ca120fd98ede80dc3a8 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 17 Dec 2024 09:35:52 +0100 Subject: [PATCH 10/18] Fix form to submit cancel reason --- .../Controller/CalendarController.php | 1 + .../views/Calendar/cancelCalendarByPerson.html.twig | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index d036b6b1e..65037c005 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -124,6 +124,7 @@ class CalendarController extends AbstractController [$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'; diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByPerson.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByPerson.html.twig index 867a5b548..d6f71cc13 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByPerson.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByPerson.html.twig @@ -6,17 +6,24 @@ {% block content %} + {{ form_start(form) }} + {{ form_row(form.cancelReason) }} + {{ form_end(form) }} + {% endblock %} From c779f53617fd37e973c2bdf60c54b67bfb4b0ab8 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 17 Dec 2024 16:04:05 +0100 Subject: [PATCH 11/18] Add translation, make reason required, and change template for form --- .../Controller/CalendarController.php | 10 ++++++++-- src/Bundle/ChillCalendarBundle/Form/CancelType.php | 6 +++--- .../cancelCalendarByAccompanyingCourse.html.twig | 13 ++++++++++--- .../translations/messages.fr.yml | 1 + 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index 65037c005..293cbeae6 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -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); } diff --git a/src/Bundle/ChillCalendarBundle/Form/CancelType.php b/src/Bundle/ChillCalendarBundle/Form/CancelType.php index c4f790c7d..dc7c4d049 100644 --- a/src/Bundle/ChillCalendarBundle/Form/CancelType.php +++ b/src/Bundle/ChillCalendarBundle/Form/CancelType.php @@ -18,13 +18,13 @@ class CancelType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { - $builder->add('cancelReason', EntityType::class, array( + $builder->add('cancelReason', EntityType::class, [ 'class' => CancelReason::class, - 'required' => false, + 'required' => true, 'choice_label' => function (CancelReason $cancelReason) { return $this->translatableStringHelper->localize($cancelReason->getName()); }, - )); + ]); } public function configureOptions(OptionsResolver $resolver) diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByAccompanyingCourse.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByAccompanyingCourse.html.twig index 10841bf9f..cc378d3cb 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByAccompanyingCourse.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByAccompanyingCourse.html.twig @@ -6,17 +6,24 @@ {% block content %} - {{ form(form) }} + {{ form_start(form) }} + + {{ form_row(form.cancelReason) }} + {{ form_end(form) }} + {% endblock %} diff --git a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml index e35a46d97..527fabb12 100644 --- a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml @@ -45,6 +45,7 @@ crud: chill_calendar: cancel_calendar_item: Annuler rendez-vous + calendar_canceled: Le rendez-vous a été annulé Document: Document d'un rendez-vous form: The main user is mandatory. He will organize the appointment.: L'utilisateur principal est obligatoire. Il est l'organisateur de l'événement. From 9d159e79facdbbaeb3d34399b6ec2bfe241de806 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 18 Dec 2024 13:20:17 +0100 Subject: [PATCH 12/18] Only show cancel button with EDIT permission --- .../Resources/views/Calendar/_list.html.twig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig index 6b11256f8..b77859e83 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig @@ -213,16 +213,18 @@ class="btn btn-show ">
  • {% endif %} + {% if is_granted('CHILL_CALENDAR_CALENDAR_EDIT', calendar) %}
  • - {% endif %}
  • {{ 'cancel'|trans }}
  • + {% endif %} + {% if is_granted('CHILL_CALENDAR_CALENDAR_DELETE', calendar) %}
  • Date: Wed, 18 Dec 2024 13:36:20 +0100 Subject: [PATCH 13/18] Use a different button type --- .../Resources/views/Calendar/_list.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig index b77859e83..46da9a911 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig @@ -221,7 +221,7 @@
  • {{ 'cancel'|trans }} + class="btn btn-remove">{{ 'cancel'|trans }}
  • {% endif %} From 761b0a3ecc88a8589b9c20f1b5853ab054a1b390 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 18 Dec 2024 13:48:56 +0100 Subject: [PATCH 14/18] Set the sms status to 'canceled' --- .../ChillCalendarBundle/Controller/CalendarController.php | 3 +-- ...t_message_canceled.twig => short_message_canceled.txt.twig} | 0 2 files changed, 1 insertion(+), 2 deletions(-) rename src/Bundle/ChillCalendarBundle/Resources/views/CalendarShortMessage/{short_message_canceled.twig => short_message_canceled.txt.twig} (100%) diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index 293cbeae6..3cd2926e5 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -119,11 +119,9 @@ 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()]; @@ -146,6 +144,7 @@ class CalendarController extends AbstractController 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')); diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/CalendarShortMessage/short_message_canceled.twig b/src/Bundle/ChillCalendarBundle/Resources/views/CalendarShortMessage/short_message_canceled.txt.twig similarity index 100% rename from src/Bundle/ChillCalendarBundle/Resources/views/CalendarShortMessage/short_message_canceled.twig rename to src/Bundle/ChillCalendarBundle/Resources/views/CalendarShortMessage/short_message_canceled.txt.twig From b1c3daf246979ecc08943595865f471eaedfe191 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 13 Jan 2025 16:16:49 +0100 Subject: [PATCH 15/18] Add a logger notice when calendar is canceled --- .../ChillCalendarBundle/Controller/CalendarController.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index 3cd2926e5..08471cd84 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -143,6 +143,11 @@ class CalendarController extends AbstractController 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(); From 63b207a2e718708417086663092ce3bf03cc3bb4 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 14 Jan 2025 10:46:02 +0100 Subject: [PATCH 16/18] Adjust display of canceled calendar items in the list --- .../Resources/views/Calendar/_list.html.twig | 19 +++++++++++++++---- .../translations/messages.fr.yml | 2 ++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig index 46da9a911..dd24c875f 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig @@ -12,6 +12,10 @@

    + {% if calendar.status == 'canceled' %} + {{ 'chill_calendar.canceled'|trans }} + + {% endif %} {% if context == 'person' and calendar.context == 'accompanying_period' %} @@ -26,13 +30,19 @@ {{ calendar.startDate|format_datetime('short', 'short') }} - {{ calendar.endDate|format_datetime('none', 'short') }} {% endif %} -

    + {% if calendar.status == 'canceled' %} + +

    + {{ 'chill_calendar.cancel_reason'|trans }}: + {{ calendar.cancelReason.name|localize_translatable_string }} +

    + {% endif %}
    {{ calendar.duration|date('%H:%I') }} {% if false == calendar.sendSMS or null == calendar.sendSMS %} - + {% else %} {% if calendar.smsStatus == 'sms_sent' %} @@ -151,7 +161,7 @@
      - {% if is_granted('CHILL_CALENDAR_DOC_EDIT', calendar) %} + {% if is_granted('CHILL_CALENDAR_DOC_EDIT', calendar) and calendar.status is not constant('STATUS_CANCELED', calendar) %} {% if templates|length == 0 %}
    • {% endif %} - {% if is_granted('CHILL_CALENDAR_CALENDAR_EDIT', calendar) %} + {% if is_granted('CHILL_CALENDAR_CALENDAR_EDIT', calendar) and calendar.status is not constant('STATUS_CANCELED', calendar) %}
    • diff --git a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml index 527fabb12..5e7c58bb4 100644 --- a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml @@ -67,6 +67,8 @@ chill_calendar: Remove a calendar document: Supprimer un document d'un rendez-vous Are you sure you want to remove the doc?: Êtes-vous sûr·e de vouloir supprimer le document associé ? Document outdated: La date et l'heure du rendez-vous ont été modifiés après la création du document + cancel_reason: Raison d'annulation + canceled: Annulé remote_ms_graph: freebusy_statuses: From b2e27700bbfb1e397cdd5aaae16ebb11d88ec89c Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 14 Jan 2025 13:31:29 +0100 Subject: [PATCH 17/18] Pipeline corrections --- .../Controller/CalendarController.php | 5 ----- .../ChillCalendarBundle/Form/CancelType.php | 17 +++++++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index 08471cd84..92db8efc6 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,12 +115,8 @@ 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()]; diff --git a/src/Bundle/ChillCalendarBundle/Form/CancelType.php b/src/Bundle/ChillCalendarBundle/Form/CancelType.php index dc7c4d049..ad41a6105 100644 --- a/src/Bundle/ChillCalendarBundle/Form/CancelType.php +++ b/src/Bundle/ChillCalendarBundle/Form/CancelType.php @@ -1,5 +1,14 @@ 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()), ]); } From f1221286f3be8441318c710c70f69210d75ff22a Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 15 Jan 2025 11:22:38 +0100 Subject: [PATCH 18/18] work on syncing with remote calendar --- .../Controller/CalendarController.php | 1 - .../Messenger/Doctrine/CalendarEntityListener.php | 11 ++++++++++- .../Messenger/Message/CalendarRemovedMessage.php | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index 8fdad6496..92db8efc6 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; diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Doctrine/CalendarEntityListener.php b/src/Bundle/ChillCalendarBundle/Messenger/Doctrine/CalendarEntityListener.php index 8f62fdcdb..00396ca5a 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Doctrine/CalendarEntityListener.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Doctrine/CalendarEntityListener.php @@ -58,7 +58,16 @@ class CalendarEntityListener public function postUpdate(Calendar $calendar, PostUpdateEventArgs $args): void { - if (!$calendar->preventEnqueueChanges) { + if ($calendar->getStatus() === $calendar::STATUS_CANCELED) { + $this->messageBus->dispatch( + new CalendarRemovedMessage( + $calendar, + $this->security->getUser() + ) + ); + } + + if (!$calendar->preventEnqueueChanges && !$calendar->getStatus() === $calendar::STATUS_CANCELED) { $this->messageBus->dispatch( new CalendarMessage( $calendar, diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarRemovedMessage.php b/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarRemovedMessage.php index 53dcea28c..7d2e88fef 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarRemovedMessage.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarRemovedMessage.php @@ -70,6 +70,8 @@ class CalendarRemovedMessage public function getRemoteId(): string { + dump($this->remoteId); + return $this->remoteId; } }