Skip to content

Commit 3b5a54f

Browse files
committed
enh(occ): make it possible to add an arbitrary number of users to a group
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
1 parent aaf2ded commit 3b5a54f

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

core/Command/Group/AddUser.php

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

@@ -45,12 +45,18 @@ 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->addUser($user);
57+
unset($user);
58+
$output->writeln('<info>user ' . $userId . ' added</info>');
5259
}
53-
$group->addUser($user);
5460
return 0;
5561
}
5662

0 commit comments

Comments
 (0)