mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
fix controller loading and add UserMenu entry
This commit is contained in:
@@ -15,6 +15,7 @@ use Chill\MainBundle\Notification\NotificationRenderer;
|
||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
use Chill\MainBundle\Repository\NotificationRepository;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
@@ -23,27 +24,34 @@ use Symfony\Component\Security\Core\Security;
|
||||
*/
|
||||
class NotificationController extends AbstractController
|
||||
{
|
||||
private $security;
|
||||
private Security $security;
|
||||
private NotificationRepository $notificationRepository;
|
||||
private NotificationRenderer $notificationRenderer;
|
||||
private PaginatorFactory $paginatorFactory;
|
||||
|
||||
public function __construct(Security $security)
|
||||
{
|
||||
public function __construct(
|
||||
Security $security,
|
||||
NotificationRepository $notificationRepository,
|
||||
NotificationRenderer $notificationRenderer,
|
||||
PaginatorFactory $paginatorFactory
|
||||
) {
|
||||
$this->security = $security;
|
||||
$this->notificationRepository = $notificationRepository;
|
||||
$this->notificationRenderer = $notificationRenderer;
|
||||
$this->paginatorFactory = $paginatorFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/show", name="chill_main_notification_show")
|
||||
*/
|
||||
public function showAction(
|
||||
NotificationRepository $notificationRepository,
|
||||
NotificationRenderer $notificationRenderer,
|
||||
PaginatorFactory $paginatorFactory
|
||||
) {
|
||||
public function showAction(): Response
|
||||
{
|
||||
$currentUser = $this->security->getUser();
|
||||
|
||||
$notificationsNbr = $notificationRepository->countAllForAttendee(($currentUser));
|
||||
$paginator = $paginatorFactory->create($notificationsNbr);
|
||||
$notificationsNbr = $this->notificationRepository->countAllForAttendee(($currentUser));
|
||||
$paginator = $this->paginatorFactory->create($notificationsNbr);
|
||||
|
||||
$notifications = $notificationRepository->findAllForAttendee(
|
||||
$notifications = $this->notificationRepository->findAllForAttendee(
|
||||
$currentUser,
|
||||
$limit = $paginator->getItemsPerPage(),
|
||||
$offset = $paginator->getCurrentPage()->getFirstItemNumber()
|
||||
@@ -53,8 +61,8 @@ class NotificationController extends AbstractController
|
||||
|
||||
foreach ($notifications as $notification) {
|
||||
$data = [
|
||||
'template' => $notificationRenderer->getTemplate($notification),
|
||||
'template_data' => $notificationRenderer->getTemplateData($notification),
|
||||
'template' => $this->notificationRenderer->getTemplate($notification),
|
||||
'template_data' => $this->notificationRenderer->getTemplateData($notification),
|
||||
'notification' => $notification,
|
||||
];
|
||||
$templateData[] = $data;
|
||||
|
Reference in New Issue
Block a user