From f5e1ecf38d7b313e838b4ff3ffb340e7cec2547b Mon Sep 17 00:00:00 2001 From: Nate Wright Date: Fri, 25 Aug 2023 12:32:08 +0100 Subject: [PATCH] pkp/pkp-lib#9253 Use shorter syntax to filter array --- api/v1/announcements/PKPAnnouncementHandler.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/api/v1/announcements/PKPAnnouncementHandler.php b/api/v1/announcements/PKPAnnouncementHandler.php index 7e835274545..b4aa58f7578 100644 --- a/api/v1/announcements/PKPAnnouncementHandler.php +++ b/api/v1/announcements/PKPAnnouncementHandler.php @@ -324,13 +324,7 @@ protected function getContextId(): int */ protected function getSiteRoleAssignments(array $roleAssignments): array { - $roleIds = array_keys($roleAssignments); - foreach ($roleIds as $roleId) { - if ($roleId !== Role::ROLE_ID_SITE_ADMIN) { - unset($roleAssignments[$roleId]); - } - } - return $roleAssignments; + return array_filter($roleAssignments, fn($key) => $key == Role::ROLE_ID_SITE_ADMIN, ARRAY_FILTER_USE_KEY); } /**