diff --git a/src/Bundle/ChillMainBundle/Controller/NotificationController.php b/src/Bundle/ChillMainBundle/Controller/NotificationController.php index a2b26832e..be6b60492 100644 --- a/src/Bundle/ChillMainBundle/Controller/NotificationController.php +++ b/src/Bundle/ChillMainBundle/Controller/NotificationController.php @@ -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") */ diff --git a/src/Bundle/ChillMainBundle/Entity/Notification.php b/src/Bundle/ChillMainBundle/Entity/Notification.php index 4e6953239..bf7aac4b3 100644 --- a/src/Bundle/ChillMainBundle/Entity/Notification.php +++ b/src/Bundle/ChillMainBundle/Entity/Notification.php @@ -12,7 +12,6 @@ declare(strict_types=1); namespace Chill\MainBundle\Entity; use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface; -use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable; use DateTimeImmutable; use DateTimeInterface; use Doctrine\Common\Collections\ArrayCollection; diff --git a/src/Bundle/ChillMainBundle/Resources/views/Notification/edit.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Notification/edit.html.twig new file mode 100644 index 000000000..a6a52acf7 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Notification/edit.html.twig @@ -0,0 +1,25 @@ +{% extends "@ChillMain/layout.html.twig" %} + +{% block content %} +