From db16a32ac3bf851b0f16034c6fbf348f3bb30577 Mon Sep 17 00:00:00 2001 From: Côme Chilliet Date: Mon, 8 Jul 2024 16:56:07 +0200 Subject: feat(occ): Add support for iterable in Base and use in in group:list and user:list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- core/Command/Group/ListCommand.php | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'core/Command/Group/ListCommand.php') diff --git a/core/Command/Group/ListCommand.php b/core/Command/Group/ListCommand.php index bea6d08c76f..f4c531bbc89 100644 --- a/core/Command/Group/ListCommand.php +++ b/core/Command/Group/ListCommand.php @@ -68,25 +68,18 @@ class ListCommand extends Base { /** * @param IGroup[] $groups - * @return array */ - private function formatGroups(array $groups, bool $addInfo = false) { - $keys = array_map(function (IGroup $group) { - return $group->getGID(); - }, $groups); - - if ($addInfo) { - $values = array_map(function (IGroup $group) { - return [ + private function formatGroups(array $groups, bool $addInfo = false): \Generator { + foreach ($groups as $group) { + if ($addInfo) { + $value = [ 'backends' => $group->getBackendNames(), 'users' => $this->usersForGroup($group), ]; - }, $groups); - } else { - $values = array_map(function (IGroup $group) { - return $this->usersForGroup($group); - }, $groups); + } else { + $value = $this->usersForGroup($group); + } + yield $group->getGID() => $value; } - return array_combine($keys, $values); } } -- cgit v1.2.3