From 032929fc4758500e2e2d4ba69eb75c385e91b317 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 8 Feb 2019 21:47:31 -0700 Subject: [PATCH] added a filter to getNotifications --- classes/admincontroller.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/classes/admincontroller.php b/classes/admincontroller.php index 4c85f3ed..74e2e6bd 100644 --- a/classes/admincontroller.php +++ b/classes/admincontroller.php @@ -832,13 +832,19 @@ class AdminController extends AdminBaseController // do we need to force a reload $refresh = (bool) ($this->data['refresh'] ?? false); + $filter = $this->data['filter'] ?? ''; + + if (!empty($filter)) { + $filter_types = array_map('trim', explode(',', $filter)); + } try { $notifications = $this->admin->getNotifications($refresh); - foreach ($notifications as $type => $type_notifications) { - $notification_data[$type] = $this->grav['twig']->processTemplate('partials/notification-block.html.twig', ['notifications' => $type_notifications]); + if (empty($filter) || in_array($type, $filter_types)) { + $notification_data[$type] = $this->grav['twig']->processTemplate('partials/notification-block.html.twig', ['notifications' => $type_notifications]); + } } $json_response = [