Skip to content

Commit

Permalink
DISPLAY-986: Review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
turegjorup committed Jul 11, 2023
1 parent fed639e commit c1d5319
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
All notable changes to this project will be documented in this file.

## [Unreleased]
- Update docker build to publish to "os2display" org on docker hup. Update github workflow to latest actions.
- Update docker build to publish to "os2display" org on docker hub. Update github workflow to latest actions.
- Updated `EventDatabaseApiFeedType` query ensuring started
but not finished events are found.
- Refactored all feed related classes and services
Expand Down
8 changes: 4 additions & 4 deletions src/Command/User/AddUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ protected function interact(InputInterface $input, OutputInterface $output): voi
$this->io->text(' > <info>Role</info>: '.$role);
} else {
$question = new ChoiceQuestion(
'Please select the users role (defaults to editor)',
['editor', 'admin'],
'Please select the user\'s role (defaults to editor)',
CommandInputValidator::ALLOWED_USER_ROLES,
0
);
$question->setErrorMessage('Color %s is invalid.');
$question->setErrorMessage('Role %s is invalid.');

$role = $helper->ask($input, $output, $question);
$output->writeln('You have just selected: '.$role);
Expand Down Expand Up @@ -284,7 +284,7 @@ private function getCommandHelp(): string
If you omit any of the required arguments, the command will ask you to
provide the missing values:
# command will ask you for the password etc
# command will ask you for the password etc.
<info>php %command.full_name%</info> <comment>email</comment>
# command will ask you for all arguments
Expand Down
5 changes: 3 additions & 2 deletions src/Utils/CommandInputValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
*/
class CommandInputValidator
{
public const ALLOWED_USER_ROLES = ['editor', 'admin'];

public function __construct(
private TenantRepository $tenantRepository,
) {}
Expand Down Expand Up @@ -95,8 +97,7 @@ public function validateRole(?string $role): string
throw new InvalidArgumentException('The role can not be empty.');
}

$allowedRoles = ['editor', 'admin'];
if (!in_array($role, $allowedRoles)) {
if (!in_array($role, self::ALLOWED_USER_ROLES)) {
throw new InvalidArgumentException('Unknown role: '.$role);
}

Expand Down

0 comments on commit c1d5319

Please sign in to comment.