mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
Notification with paginitation
This commit is contained in:
@@ -3,12 +3,16 @@
|
||||
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;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/notification")
|
||||
*/
|
||||
class NotificationController extends AbstractController
|
||||
{
|
||||
private $security;
|
||||
@@ -18,11 +22,23 @@ class NotificationController extends AbstractController
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
public function showAction(NotificationRepository $notificationRepository, NotificationRenderer $notificationRenderer)
|
||||
|
||||
/**
|
||||
* @Route("/show", name="chill_main_notification_show")
|
||||
*/
|
||||
public function showAction(
|
||||
NotificationRepository $notificationRepository, NotificationRenderer $notificationRenderer,
|
||||
PaginatorFactory $paginatorFactory)
|
||||
{
|
||||
$currentUser = $this->security->getUser();
|
||||
|
||||
$notifications = $notificationRepository->findAllForAttendee($currentUser);
|
||||
$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) {
|
||||
@@ -34,9 +50,10 @@ class NotificationController extends AbstractController
|
||||
$templateData[] = $data;
|
||||
}
|
||||
|
||||
return $this->render('ChillMainBundle:Notification:show.html.twig', [
|
||||
return $this->render('@ChillMain/Notification/show.html.twig', [
|
||||
'datas' => $templateData,
|
||||
'notifications' => $notifications,
|
||||
'notifications' => $notifications,
|
||||
'paginator' => $paginator,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user