mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
notification: add comment in show and append comment
This commit is contained in:
@@ -12,7 +12,9 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Controller;
|
||||
|
||||
use Chill\MainBundle\Entity\Notification;
|
||||
use Chill\MainBundle\Entity\NotificationComment;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Form\NotificationCommentType;
|
||||
use Chill\MainBundle\Form\NotificationType;
|
||||
use Chill\MainBundle\Notification\Exception\NotificationHandlerNotFound;
|
||||
use Chill\MainBundle\Notification\NotificationHandlerManager;
|
||||
@@ -177,11 +179,28 @@ class NotificationController extends AbstractController
|
||||
{
|
||||
$this->denyAccessUnlessGranted(NotificationVoter::SEE, $notification);
|
||||
|
||||
$notification->addComment($appendComment = new NotificationComment());
|
||||
$appendCommentForm = $this->createForm(NotificationCommentType::class, $appendComment);
|
||||
$appendCommentForm->handleRequest($request);
|
||||
|
||||
if ($appendCommentForm->isSubmitted() && $appendCommentForm->isValid()) {
|
||||
$this->em->persist($appendComment);
|
||||
$this->em->flush();
|
||||
|
||||
$this->addFlash('success', $this->translator->trans('notification.comment_appended'));
|
||||
|
||||
return $this->redirectToRoute('chill_main_notification_show', [
|
||||
'id' => $notification->getId(),
|
||||
]);
|
||||
}
|
||||
|
||||
$response = $this->render('@ChillMain/Notification/show.html.twig', [
|
||||
'notification' => $notification,
|
||||
'handler' => $this->notificationHandlerManager->getHandler($notification),
|
||||
'appendCommentForm' => $appendCommentForm->createView(),
|
||||
]);
|
||||
|
||||
// we mark the notification as read after having computed the response
|
||||
if ($this->getUser() instanceof User && !$notification->isReadBy($this->getUser())) {
|
||||
$notification->markAsReadBy($this->getUser());
|
||||
$this->em->flush();
|
||||
|
Reference in New Issue
Block a user