chill-bundles/src/Bundle/ChillMainBundle/Controller/NotificationController.php
2021-06-18 18:05:02 +02:00

43 lines
1.4 KiB
PHP

<?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,
]);
}
}