diff --git a/src/Bundle/ChillMainBundle/Controller/NotificationController.php b/src/Bundle/ChillMainBundle/Controller/NotificationController.php index c3ec0e549..df38c15d9 100644 --- a/src/Bundle/ChillMainBundle/Controller/NotificationController.php +++ b/src/Bundle/ChillMainBundle/Controller/NotificationController.php @@ -18,6 +18,7 @@ use Chill\MainBundle\Notification\Exception\NotificationHandlerNotFound; use Chill\MainBundle\Notification\NotificationHandlerManager; use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\MainBundle\Repository\NotificationRepository; +use Chill\MainBundle\Security\Authorization\NotificationVoter; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -169,6 +170,26 @@ class NotificationController extends AbstractController ]); } + /** + * @Route("/{id}/show", name="chill_main_notification_show") + */ + public function showAction(Notification $notification, Request $request): Response + { + $this->denyAccessUnlessGranted(NotificationVoter::SEE, $notification); + + $response = $this->render('@ChillMain/Notification/show.html.twig', [ + 'notification' => $notification, + 'handler' => $this->notificationHandlerManager->getHandler($notification), + ]); + + if ($this->getUser() instanceof User && !$notification->isReadBy($this->getUser())) { + $notification->markAsReadBy($this->getUser()); + $this->em->flush(); + } + + return $response; + } + private function countUnread(): array { return [ diff --git a/src/Bundle/ChillMainBundle/Resources/views/Notification/list.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Notification/list.html.twig index 4a1f504f4..96074e14d 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Notification/list.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Notification/list.html.twig @@ -12,9 +12,11 @@
- {{ notification.message|u.truncate(250, '…', false)|chill_markdown_to_html }} -+
+ {{ notification.message|u.truncate(250, '…', false)|chill_markdown_to_html }} ++