mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
60 lines
1.9 KiB
PHP
60 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace Chill\MainBundle\Controller;
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
use Chill\MainBundle\Repository\NotificationRepository;
|
|
use Chill\MainBundle\Notification\NotificationRenderer;
|
|
use Symfony\Component\Security\Core\Security;
|
|
use Symfony\Component\Routing\Annotation\Route;
|
|
use Chill\MainBundle\Pagination\PaginatorFactory;
|
|
|
|
|
|
/**
|
|
* @Route("/{_locale}/notification")
|
|
*/
|
|
class NotificationController extends AbstractController
|
|
{
|
|
private $security;
|
|
|
|
public function __construct(Security $security)
|
|
{
|
|
$this->security = $security;
|
|
}
|
|
|
|
|
|
/**
|
|
* @Route("/show", name="chill_main_notification_show")
|
|
*/
|
|
public function showAction(
|
|
NotificationRepository $notificationRepository, NotificationRenderer $notificationRenderer,
|
|
PaginatorFactory $paginatorFactory)
|
|
{
|
|
$currentUser = $this->security->getUser();
|
|
|
|
$notificationsNbr = $notificationRepository->countAllForAttendee(($currentUser));
|
|
$paginator = $paginatorFactory->create($notificationsNbr);
|
|
|
|
$notifications = $notificationRepository->findAllForAttendee(
|
|
$currentUser,
|
|
$limit=$paginator->getItemsPerPage(),
|
|
$offset= $paginator->getCurrentPage()->getFirstItemNumber());
|
|
|
|
$templateData = array();
|
|
foreach ($notifications as $notification) {
|
|
$data = [
|
|
'template' => $notificationRenderer->getTemplate($notification),
|
|
'template_data' => $notificationRenderer->getTemplateData($notification),
|
|
'notification' => $notification
|
|
];
|
|
$templateData[] = $data;
|
|
}
|
|
|
|
return $this->render('@ChillMain/Notification/show.html.twig', [
|
|
'datas' => $templateData,
|
|
'notifications' => $notifications,
|
|
'paginator' => $paginator,
|
|
]);
|
|
}
|
|
}
|