| Conditions | 4 |
| Paths | 4 |
| Total Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | protected function executeRoleCommand(OutputInterface $output, $username, $super, $role) |
||
| 27 | { |
||
| 28 | $user = $this->userManager->findUserByUsername($username); |
||
| 29 | |||
| 30 | if (!$user) { |
||
| 31 | throw new InvalidArgumentException(sprintf('User identified by "%s" username does not exist.', $username)); |
||
| 32 | } |
||
| 33 | |||
| 34 | if ($super) { |
||
| 35 | $user->setSuperAdmin(true); |
||
| 36 | $output->writeln(sprintf('User "%s" has been promoted as a super administrator. This change will not apply until the user logs out and back in again.', $username)); |
||
| 37 | } else { |
||
| 38 | if ($user->hasRole($role)) { |
||
| 39 | $output->writeln(sprintf('User "%s" did already have "%s" role.', $username, $role)); |
||
| 40 | |||
| 41 | return; |
||
| 42 | } |
||
| 43 | |||
| 44 | $user->addRole($role); |
||
| 45 | $output->writeln(sprintf('Role "%s" has been added to user "%s". This change will not apply until the user logs out and back in again.', $role, $username)); |
||
| 46 | } |
||
| 47 | |||
| 48 | $this->userManager->updateUser($user); |
||
| 49 | |||
| 50 | return 0; |
||
| 51 | } |
||
| 52 | } |
||
| 53 |