recreate calendar range when an event is deleted

This commit is contained in:
2022-07-01 13:43:30 +02:00
parent 0276ec1bc7
commit 87403e509f
9 changed files with 160 additions and 19 deletions

View File

@@ -80,12 +80,13 @@ class CalendarController extends AbstractController
*
* @Route("/{_locale}/calendar/{id}/delete", name="chill_calendar_calendar_delete")
*/
public function deleteAction(Request $request, int $id)
public function deleteAction(Request $request, Calendar $entity)
{
$view = null;
$em = $this->getDoctrine()->getManager();
[$user, $accompanyingPeriod] = $this->getEntity($request);
$accompanyingPeriod = $entity->getAccompanyingPeriod();
$user = null; // TODO legacy code ? remove it ?
if ($accompanyingPeriod instanceof AccompanyingPeriod) {
$view = '@ChillCalendar/Calendar/confirm_deleteByAccompanyingCourse.html.twig';
@@ -93,14 +94,7 @@ class CalendarController extends AbstractController
$view = '@ChillCalendar/Calendar/confirm_deleteByUser.html.twig';
}
/** @var Calendar $entity */
$entity = $em->getRepository(\Chill\CalendarBundle\Entity\Calendar::class)->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Calendar entity.');
}
$form = $this->createDeleteForm($id, $user, $accompanyingPeriod);
$form = $this->createDeleteForm($entity->getId(), $user, $accompanyingPeriod);
if ($request->getMethod() === Request::METHOD_DELETE) {
$form->handleRequest($request);
@@ -119,7 +113,7 @@ class CalendarController extends AbstractController
$params = $this->buildParamsToUrl($user, $accompanyingPeriod);
return $this->redirectToRoute('chill_calendar_calendar_list', $params);
return $this->redirectToRoute('chill_calendar_calendar_list_by_period', $params);
}
}