mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
notification: add show action
This commit is contained in:
@@ -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 [
|
||||
|
Reference in New Issue
Block a user