allow to edit notification

This commit is contained in:
2021-12-29 15:24:52 +01:00
parent 478c3b3247
commit 9d638fe897
5 changed files with 70 additions and 6 deletions

View File

@@ -120,6 +120,36 @@ class NotificationController extends AbstractController
]);
}
/**
* @Route("/{id}/edit", name="chill_main_notification_edit")
*/
public function editAction(Notification $notification, Request $request): Response
{
$this->denyAccessUnlessGranted(NotificationVoter::UPDATE, $notification);
$form = $this->createForm(NotificationType::class, $notification);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->em->flush();
$this->addFlash('success', $this->translator->trans('notification.Notification updated'));
if ($request->query->has('returnPath')) {
return new RedirectResponse($request->query->get('returnPath'));
}
return $this->redirectToRoute('chill_main_notification_my');
}
return $this->render('@ChillMain/Notification/edit.html.twig', [
'form' => $form->createView(),
'handler' => $this->notificationHandlerManager->getHandler($notification),
'notification' => $notification,
]);
}
/**
* @Route("/inbox", name="chill_main_notification_my")
*/