@@ 76-108 (lines=33) @@ | ||
73 | /** |
|
74 | * {@inheritdoc} |
|
75 | */ |
|
76 | protected function interact(InputInterface $input, OutputInterface $output) |
|
77 | { |
|
78 | $questions = []; |
|
79 | ||
80 | if (!$input->getArgument('username')) { |
|
81 | $question = new Question('Please choose a username:'); |
|
82 | $question->setValidator(function ($username) { |
|
83 | if (empty($username)) { |
|
84 | throw new \Exception('Username can not be empty'); |
|
85 | } |
|
86 | ||
87 | return $username; |
|
88 | }); |
|
89 | $questions['username'] = $question; |
|
90 | } |
|
91 | ||
92 | if ((true !== $input->getOption('super')) && !$input->getArgument('role')) { |
|
93 | $question = new Question('Please choose a role:'); |
|
94 | $question->setValidator(function ($role) { |
|
95 | if (empty($role)) { |
|
96 | throw new \Exception('Role can not be empty'); |
|
97 | } |
|
98 | ||
99 | return $role; |
|
100 | }); |
|
101 | $questions['role'] = $question; |
|
102 | } |
|
103 | ||
104 | foreach ($questions as $name => $question) { |
|
105 | $answer = $this->getHelper('question')->ask($input, $output, $question); |
|
106 | $input->setArgument($name, $answer); |
|
107 | } |
|
108 | } |
|
109 | } |
|
110 |
@@ 69-102 (lines=34) @@ | ||
66 | /** |
|
67 | * {@inheritdoc} |
|
68 | */ |
|
69 | protected function interact(InputInterface $input, OutputInterface $output) |
|
70 | { |
|
71 | $questions = []; |
|
72 | ||
73 | if (!$input->getArgument('username')) { |
|
74 | $question = new Question('Please give the username:'); |
|
75 | $question->setValidator(function ($username) { |
|
76 | if (empty($username)) { |
|
77 | throw new Exception('Username can not be empty'); |
|
78 | } |
|
79 | ||
80 | return $username; |
|
81 | }); |
|
82 | $questions['username'] = $question; |
|
83 | } |
|
84 | ||
85 | if (!$input->getArgument('password')) { |
|
86 | $question = new Question('Please enter the new password:'); |
|
87 | $question->setValidator(function ($password) { |
|
88 | if (empty($password)) { |
|
89 | throw new Exception('Password can not be empty'); |
|
90 | } |
|
91 | ||
92 | return $password; |
|
93 | }); |
|
94 | $question->setHidden(true); |
|
95 | $questions['password'] = $question; |
|
96 | } |
|
97 | ||
98 | foreach ($questions as $name => $question) { |
|
99 | $answer = $this->getHelper('question')->ask($input, $output, $question); |
|
100 | $input->setArgument($name, $answer); |
|
101 | } |
|
102 | } |
|
103 | } |
|
104 |