Display notification using services (draft)

This commit is contained in:
Marc Ducobu
2021-06-18 18:05:02 +02:00
parent bdf691a063
commit 282db51f06
15 changed files with 208 additions and 1 deletions

View File

@@ -0,0 +1,42 @@
<?php
namespace Chill\MainBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Repository\NotificationRepository;
use Chill\MainBundle\Notification\NotificationRenderer;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Security;
class NotificationController extends AbstractController
{
private $security;
public function __construct(Security $security)
{
$this->security = $security;
}
public function showAction(NotificationRepository $notificationRepository, NotificationRenderer $notificationRenderer)
{
$currentUser = $this->security->getUser();
$notifications = $notificationRepository->findAllForAttendee($currentUser);
$templateData = array();
foreach ($notifications as $notification) {
$data = [
'template' => $notificationRenderer->getTemplate($notification),
'template_data' => $notificationRenderer->getTemplateData($notification),
'notification' => $notification
];
$templateData[] = $data;
}
return $this->render('ChillMainBundle:Notification:show.html.twig', [
'datas' => $templateData,
'notifications' => $notifications,
]);
}
}