mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
Merge branch '1.5' into 1.6
* 1.5: [SyliusUserBundle] Improve output of PromoteUserCommand and DemoteUserCommand
This commit is contained in:
commit
5b8d1771d6
2 changed files with 12 additions and 4 deletions
|
|
@ -49,21 +49,25 @@ EOT
|
|||
protected function executeRoleCommand(InputInterface $input, OutputInterface $output, UserInterface $user, array $securityRoles): void
|
||||
{
|
||||
$error = false;
|
||||
$successMessages = [];
|
||||
|
||||
foreach ($securityRoles as $securityRole) {
|
||||
if (!$user->hasRole($securityRole)) {
|
||||
$output->writeln(sprintf('<error>User "%s" didn\'t have "%s" Security role.</error>', $user->getEmail(), $securityRole));
|
||||
$output->writeln(sprintf('<error>User "%s" doesn\'t have "%s" Security role.</error>', $user->getEmail(), $securityRole));
|
||||
$error = true;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$user->removeRole($securityRole);
|
||||
$output->writeln(sprintf('Security role <comment>%s</comment> has been removed from user <comment>%s</comment>', $securityRole, $user->getEmail()));
|
||||
$successMessages[] = sprintf('Security role <comment>%s</comment> has been removed from user <comment>%s</comment>', $securityRole, $user->getEmail());
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$output->writeln($successMessages);
|
||||
$this->getEntityManager($input->getOption('user-type'))->flush();
|
||||
} else {
|
||||
$output->writeln(sprintf('<error>No roles removed from User "%s".</error>', $user->getEmail()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,21 +49,25 @@ EOT
|
|||
protected function executeRoleCommand(InputInterface $input, OutputInterface $output, UserInterface $user, array $securityRoles): void
|
||||
{
|
||||
$error = false;
|
||||
$successMessages = [];
|
||||
|
||||
foreach ($securityRoles as $securityRole) {
|
||||
if ($user->hasRole($securityRole)) {
|
||||
$output->writeln(sprintf('<error>User "%s" did already have "%s" security role.</error>', $user->getEmail(), $securityRole));
|
||||
$output->writeln(sprintf('<error>User "%s" already has "%s" security role.</error>', $user->getEmail(), $securityRole));
|
||||
$error = true;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$user->addRole($securityRole);
|
||||
$output->writeln(sprintf('Security role <comment>%s</comment> has been added to user <comment>%s</comment>', $securityRole, $user->getEmail()));
|
||||
$successMessages[] = sprintf('Security role <comment>%s</comment> has been added to user <comment>%s</comment>', $securityRole, $user->getEmail());
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$output->writeln($successMessages);
|
||||
$this->getEntityManager($input->getOption('user-type'))->flush();
|
||||
} else {
|
||||
$output->writeln(sprintf('<error>No roles added to User "%s".</error>', $user->getEmail()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue