Skip to content

Commit

Permalink
Fixed issue when running kuma:user:create with --no-interaction flag (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
veloxy authored and sandergo90 committed Sep 7, 2018
1 parent f6a8834 commit ee0e067
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/Kunstmaan/AdminBundle/Command/CreateUserCommand.php
Expand Up @@ -62,6 +62,12 @@ protected function configure()
);
}

protected function initialize(InputInterface $input, OutputInterface $output)
{
$this->groups = $this->getGroups();
}


/**
* Executes the current command.
*
Expand Down Expand Up @@ -217,16 +223,6 @@ protected function interact(InputInterface $input, OutputInterface $output)
$input->setArgument('locale', $locale);
}

$this->groups = $this->getContainer()->get('fos_user.group_manager')->findGroups();

// reindexing the array, using the db id as the key
$newGroups = [];
foreach($this->groups as $group) {
$newGroups[$group->getId()] = $group;
}

$this->groups = $newGroups;

if (!$input->getOption('group')) {
$question = new ChoiceQuestion(
'Please enter the group(s) the user should be a member of (multiple possible, separated by comma):',
Expand Down Expand Up @@ -260,4 +256,17 @@ protected function interact(InputInterface $input, OutputInterface $output)
$input->setOption('group', $groups);
}
}

private function getGroups()
{
$groups = $this->getContainer()->get('fos_user.group_manager')->findGroups();

// reindexing the array, using the db id as the key
$newGroups = [];
foreach($groups as $group) {
$newGroups[$group->getId()] = $group;
}

return $newGroups;
}
}

0 comments on commit ee0e067

Please sign in to comment.