Skip to content

Commit f7395ce

Browse files
committed
IBX-9060: Updated NotificationQuery references and adjusted NotificationController for stricter type handling
1 parent 9c60177 commit f7395ce

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

phpstan-baseline.neon

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -726,12 +726,6 @@ parameters:
726726
count: 1
727727
path: src/bundle/Controller/LocationController.php
728728

729-
-
730-
message: '#^Parameter \#1 \$content of class Symfony\\Component\\HttpFoundation\\Response constructor expects string\|null, string\|false given\.$#'
731-
identifier: argument.type
732-
count: 1
733-
path: src/bundle/Controller/NotificationController.php
734-
735729
-
736730
message: '#^Argument of an invalid type array\<Ibexa\\Contracts\\Core\\Repository\\Values\\ObjectState\\ObjectState\>\|null supplied for foreach, only iterables are supported\.$#'
737731
identifier: foreach.nonIterable

src/bundle/Controller/NotificationController.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
use Ibexa\Bundle\AdminUi\Form\Type\SearchType;
1919
use Ibexa\Contracts\AdminUi\Controller\Controller;
2020
use Ibexa\Contracts\Core\Repository\NotificationService;
21+
use Ibexa\Contracts\Core\Repository\Values\Notification\Notification;
2122
use Ibexa\Contracts\Core\Repository\Values\Notification\Query\Criterion;
22-
use Ibexa\Contracts\Core\Repository\Values\Notification\Query\Criterion\NotificationQuery;
23+
use Ibexa\Contracts\Core\Repository\Values\Notification\Query\NotificationQuery;
2324
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
2425
use Ibexa\Core\Notification\Renderer\Registry;
2526
use InvalidArgumentException;
@@ -93,7 +94,7 @@ public function renderNotificationsPageAction(Request $request, int $page): Resp
9394
$searchForm->handleRequest($request);
9495

9596
$query = new NotificationQuery();
96-
if ($searchForm->isSubmitted() && $searchForm->isValid()) {
97+
if ($searchForm->isSubmitted() && $searchForm->isValid() && $searchForm->getData() instanceof SearchQueryData) {
9798
$query = $this->buildQuery($searchForm->getData());
9899
}
99100

@@ -162,12 +163,15 @@ private function buildQuery(SearchQueryData $data): NotificationQuery
162163
return new NotificationQuery($criteria);
163164
}
164165

166+
/**
167+
* @param Pagerfanta<\Ibexa\Contracts\Core\Repository\Values\Notification\Notification> $pagerfanta
168+
*/
165169
private function createNotificationSelectionData(Pagerfanta $pagerfanta): NotificationSelectionData
166170
{
167171
$notifications = [];
168172

169173
foreach ($pagerfanta->getCurrentPageResults() as $notification) {
170-
$notifications[$notification->id] = false;
174+
$notifications[] = $notification;
171175
}
172176

173177
return new NotificationSelectionData($notifications);
@@ -200,7 +204,7 @@ public function countNotificationsAction(): JsonResponse
200204
* server service for websocket connection), so * we need a way to mark notification
201205
* as read. AJAX call is fine.
202206
*/
203-
public function markNotificationAsReadAction(Request $request, mixed $notificationId): JsonResponse
207+
public function markNotificationAsReadAction(Request $request, $notificationId): JsonResponse
204208
{
205209
$response = new JsonResponse();
206210

@@ -283,7 +287,7 @@ public function markAllNotificationsAsReadAction(Request $request): JsonResponse
283287
}
284288
}
285289

286-
public function markNotificationAsUnreadAction(Request $request, mixed $notificationId): JsonResponse
290+
public function markNotificationAsUnreadAction(Request $request, $notificationId): JsonResponse
287291
{
288292
$response = new JsonResponse();
289293

@@ -307,7 +311,7 @@ public function markNotificationAsUnreadAction(Request $request, mixed $notifica
307311
return $response;
308312
}
309313

310-
public function deleteNotificationAction(Request $request, mixed $notificationId): JsonResponse
314+
public function deleteNotificationAction(Request $request, $notificationId): JsonResponse
311315
{
312316
$response = new JsonResponse();
313317

src/lib/Pagination/Pagerfanta/NotificationAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
use Ibexa\Contracts\Core\Repository\NotificationService;
1111
use Ibexa\Contracts\Core\Repository\Values\Notification\NotificationList;
12-
use Ibexa\Contracts\Core\Repository\Values\Notification\Query\Criterion\NotificationQuery;
12+
use Ibexa\Contracts\Core\Repository\Values\Notification\Query\NotificationQuery;
1313
use Pagerfanta\Adapter\AdapterInterface;
1414

1515
/**

0 commit comments

Comments
 (0)