Skip to content

Commit

Permalink
#9253 Use shorter syntax to filter array
Browse files Browse the repository at this point in the history
  • Loading branch information
NateWr authored and asmecher committed Nov 8, 2023
1 parent 45e1c67 commit f5e1ecf
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions api/v1/announcements/PKPAnnouncementHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit f5e1ecf

Please sign in to comment.