mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
Display notification using services (draft)
This commit is contained in:
@@ -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,
|
||||
]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user