Skip to content

Commit 3010f81

Browse files
tbialczalbozek
authored andcommitted
IBX-9060: Replaced loadNotifications with findNotifications in NotificationAdapter
1 parent 8f8cace commit 3010f81

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/bundle/Controller/NotificationController.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ public function getNotificationsAction(Request $request, int $offset, int $limit
6464
$response = new JsonResponse();
6565

6666
try {
67-
$notificationList = $this->notificationService->loadNotifications(
68-
new NotificationQuery([], $offset, $limit)
69-
);
67+
$notificationList = $this->notificationService->loadNotifications($offset, $limit);
7068
$response->setData([
7169
'pending' => $this->notificationService->getPendingNotificationCount(),
7270
'total' => $notificationList->totalCount,
@@ -84,9 +82,7 @@ public function getNotificationsAction(Request $request, int $offset, int $limit
8482

8583
public function renderNotificationsPageAction(Request $request, int $page): Response
8684
{
87-
$allNotifications = $this->notificationService->loadNotifications(
88-
new NotificationQuery([], 0, PHP_INT_MAX)
89-
)->items;
85+
$allNotifications = $this->notificationService->loadNotifications(0, PHP_INT_MAX)->items;
9086

9187
$notificationTypes = array_unique(array_column($allNotifications, 'type'));
9288
sort($notificationTypes);
@@ -101,13 +97,13 @@ public function renderNotificationsPageAction(Request $request, int $page): Resp
10197
$query = $this->buildQuery($searchForm->getData());
10298
}
10399

104-
$query->offset = ($page - 1) * $this->configResolver->getParameter('pagination.notification_limit');
105-
$query->limit = $this->configResolver->getParameter('pagination.notification_limit');
100+
$query->setOffset(($page - 1) * $this->configResolver->getParameter('pagination.notification_limit'));
101+
$query->setLimit($this->configResolver->getParameter('pagination.notification_limit'));
106102

107103
$pagerfanta = new Pagerfanta(
108104
new NotificationAdapter($this->notificationService, $query)
109105
);
110-
$pagerfanta->setMaxPerPage($query->limit);
106+
$pagerfanta->setMaxPerPage($query->getLimit());
111107
$pagerfanta->setCurrentPage(min($page, $pagerfanta->getNbPages()));
112108

113109
$notifications = [];
@@ -272,9 +268,7 @@ public function markAllNotificationsAsReadAction(Request $request): JsonResponse
272268
$response = new JsonResponse();
273269

274270
try {
275-
$notifications = $this->notificationService->loadNotifications(
276-
new NotificationQuery([], 0, PHP_INT_MAX)
277-
)->items;
271+
$notifications = $this->notificationService->loadNotifications(0, PHP_INT_MAX)->items;
278272

279273
foreach ($notifications as $notification) {
280274
$this->notificationService->markNotificationAsRead($notification);

0 commit comments

Comments
 (0)