| @@ -49,80 +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 | - $questions = []; | |
| 90 | - | |
| 91 | -        if (!$input->getArgument('username')) { | |
| 92 | -            $question = new Question('Please choose a username:'); | |
| 93 | - $question->setValidator( | |
| 94 | -                static function ($username) { | |
| 95 | -                    if (empty($username)) { | |
| 96 | -                        throw new Exception('Username can not be empty'); | |
| 97 | - } | |
| 98 | - | |
| 99 | - return $username; | |
| 100 | - }); | |
| 101 | - $questions['username'] = $question; | |
| 102 | - } | |
| 103 | - | |
| 104 | -        if (!$input->getArgument('email')) { | |
| 105 | -            $question = new Question('Please choose an email (leave blank to use same as username):'); | |
| 106 | - $questions['email'] = $question; | |
| 107 | - } | |
| 108 | - | |
| 109 | -        if (!$input->getArgument('password')) { | |
| 110 | -            $question = new Question('Please choose a password:'); | |
| 111 | - $question->setValidator( | |
| 112 | -                static function ($password) { | |
| 113 | -                    if (empty($password)) { | |
| 114 | -                        throw new Exception('Password can not be empty'); | |
| 115 | - } | |
| 116 | - | |
| 117 | - return $password; | |
| 118 | - }); | |
| 119 | - $question->setHidden(true); | |
| 120 | - $questions['password'] = $question; | |
| 121 | - } | |
| 122 | - | |
| 123 | -        foreach ($questions as $name => $question) { | |
| 124 | -            $answer = $this->getHelper('question')->ask($input, $output, $question); | |
| 125 | - $input->setArgument($name, $answer); | |
| 126 | - } | |
| 127 | - } | |
| 128 | -} | |
| @@ -49,80 +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 | - $questions = []; | |
| 90 | - | |
| 91 | -        if (!$input->getArgument('username')) { | |
| 92 | -            $question = new Question('Please choose a username:'); | |
| 93 | - $question->setValidator( | |
| 94 | -                static function ($username) { | |
| 95 | -                    if (empty($username)) { | |
| 96 | -                        throw new Exception('Username can not be empty'); | |
| 97 | - } | |
| 98 | - | |
| 99 | - return $username; | |
| 100 | - }); | |
| 101 | - $questions['username'] = $question; | |
| 102 | - } | |
| 103 | - | |
| 104 | -        if (!$input->getArgument('email')) { | |
| 105 | -            $question = new Question('Please choose an email (leave blank to use same as username):'); | |
| 106 | - $questions['email'] = $question; | |
| 107 | - } | |
| 108 | - | |
| 109 | -        if (!$input->getArgument('password')) { | |
| 110 | -            $question = new Question('Please choose a password:'); | |
| 111 | - $question->setValidator( | |
| 112 | -                static function ($password) { | |
| 113 | -                    if (empty($password)) { | |
| 114 | -                        throw new Exception('Password can not be empty'); | |
| 115 | - } | |
| 116 | - | |
| 117 | - return $password; | |
| 118 | - }); | |
| 119 | - $question->setHidden(true); | |
| 120 | - $questions['password'] = $question; | |
| 121 | - } | |
| 122 | - | |
| 123 | -        foreach ($questions as $name => $question) { | |
| 124 | -            $answer = $this->getHelper('question')->ask($input, $output, $question); | |
| 125 | - $input->setArgument($name, $answer); | |
| 126 | - } | |
| 127 | - } | |
| 128 | -} | |