Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions apps/settings/lib/Command/AdminDelegation/Add.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,24 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$io = new SymfonyStyle($input, $output);
$settingClass = $input->getArgument('settingClass');
if (!in_array(IDelegatedSettings::class, (array) class_implements($settingClass), true)) {
$io->error('The specified class isn’t a valid delegated setting.');
$io->error('The specified class is not a valid delegated setting.');
return 2;
}

$groupId = $input->getArgument('groupId');
if (!$this->groupManager->groupExists($groupId)) {
$io->error('The specified group didn’t exist.');
$io->error('The specified group does not exist.');
return 3;
}

$groups = $this->authorizedGroupService->findExistingGroupsForClass($settingClass);
foreach ($groups as $group) {
if ($group->getGroupId() === $groupId) {
$io->error('The specified group has already been delegated to.');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not clear, it should say it has already been delegated the same setting or something, no?

return 4;
}
}

$this->authorizedGroupService->create($groupId, $settingClass);

$io->success('Administration of '.$settingClass.' delegated to '.$groupId.'.');
Expand Down