Skip to content

Commit 026dde3

Browse files
committed
enh(occ): make it possible to remove an arbitrary number of users to a group
Signed-off-by: Enjeck C. <patrathewhiz@gmail.com>
1 parent 35283f2 commit 026dde3

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

core/Command/Group/RemoveUser.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ protected function configure() {
3434
'group to remove the user from'
3535
)->addArgument(
3636
'user',
37-
InputArgument::REQUIRED,
38-
'user to remove from the group'
37+
InputArgument::REQUIRED + InputArgument::IS_ARRAY,
38+
'users to remove from the group'
3939
);
4040
}
4141

@@ -45,12 +45,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4545
$output->writeln('<error>group not found</error>');
4646
return 1;
4747
}
48-
$user = $this->userManager->get($input->getArgument('user'));
49-
if (is_null($user)) {
50-
$output->writeln('<error>user not found</error>');
51-
return 1;
48+
49+
$users = (array)$input->getArgument('user');
50+
foreach ($users as $userId) {
51+
$user = $this->userManager->get($userId);
52+
if (is_null($user)) {
53+
$output->writeln('<error>user ' . $userId . ' not found</error>');
54+
return 1;
55+
}
56+
$group->removeUser($user);
57+
unset($user);
58+
$output->writeln('<info>user ' . $userId . ' removed</info>');
5259
}
53-
$group->removeUser($user);
60+
5461
return 0;
5562
}
5663

0 commit comments

Comments
 (0)