@@ -49,76 +49,3 @@ |
||
49 | 49 | new InputOption('overwrite', null, InputOption::VALUE_NONE, 'Overwrite the user if they already exist'), |
50 | 50 | ]) |
51 | 51 | ->setHelp(<<<'EOT' |
52 | - The <info>silverback:api-component:user:create</info> command creates a user: |
|
53 | - <info>php %command.full_name% daniel</info> |
|
54 | - This interactive shell will ask you for an email and then a password. |
|
55 | - You can alternatively specify the email and password as the second and third arguments: |
|
56 | - <info>php %command.full_name% daniel [email protected] mypassword</info> |
|
57 | - You can create a super admin via the super-admin flag: |
|
58 | - <info>php %command.full_name% admin --super-admin</info> |
|
59 | - You can create an inactive user (will not be able to log in): |
|
60 | - <info>php %command.full_name% disabled_user --inactive</info> |
|
61 | - You can overwrite a user if they already exist: |
|
62 | - <info>php %command.full_name% existing_username --overwrite</info> |
|
63 | - EOT |
|
64 | - ); |
|
65 | - } |
|
66 | - |
|
67 | - /** |
|
68 | - * {@inheritdoc} |
|
69 | - */ |
|
70 | - protected function execute(InputInterface $input, OutputInterface $output): void |
|
71 | - { |
|
72 | - $username = (string) $input->getArgument('username'); |
|
73 | - $email = (string) $input->getArgument('email'); |
|
74 | - $password = (string) $input->getArgument('password'); |
|
75 | - $inactive = $input->getOption('inactive'); |
|
76 | - $superadmin = $input->getOption('super-admin'); |
|
77 | - $overwrite = $input->getOption('overwrite'); |
|
78 | - |
|
79 | - $this->userFactory->create($username, $password, $email, $inactive, $superadmin, $overwrite); |
|
80 | - |
|
81 | - $output->writeln(sprintf('Created user <comment>%s</comment>', $username)); |
|
82 | - } |
|
83 | - |
|
84 | - /** |
|
85 | - * {@inheritdoc} |
|
86 | - */ |
|
87 | - protected function interact(InputInterface $input, OutputInterface $output): void |
|
88 | - { |
|
89 | - $notEmptyValidator = static function (string $label) { |
|
90 | - return static function (string $string) use ($label) { |
|
91 | - if (empty($string)) { |
|
92 | - throw new Exception($label . ' can not be empty'); |
|
93 | - } |
|
94 | - |
|
95 | - return $string; |
|
96 | - }; |
|
97 | - }; |
|
98 | - |
|
99 | - $questions = []; |
|
100 | - |
|
101 | - if (!$input->getArgument('username')) { |
|
102 | - $question = new Question('Please choose a username:'); |
|
103 | - $question->setValidator($notEmptyValidator('Username')); |
|
104 | - $questions['username'] = $question; |
|
105 | - } |
|
106 | - |
|
107 | - if (!$input->getArgument('email')) { |
|
108 | - $question = new Question('Please choose an email (leave blank to use same as username):'); |
|
109 | - $questions['email'] = $question; |
|
110 | - } |
|
111 | - |
|
112 | - if (!$input->getArgument('password')) { |
|
113 | - $question = new Question('Please choose a password:'); |
|
114 | - $question->setValidator($notEmptyValidator('Password')); |
|
115 | - $question->setHidden(true); |
|
116 | - $questions['password'] = $question; |
|
117 | - } |
|
118 | - |
|
119 | - foreach ($questions as $name => $question) { |
|
120 | - $answer = $this->getHelper('question')->ask($input, $output, $question); |
|
121 | - $input->setArgument($name, $answer); |
|
122 | - } |
|
123 | - } |
|
124 | -} |