mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-02 13:03:50 +00:00
recreate calendar range when an event is deleted
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user