Refactored InstallCommand (+ removed localization from InstallCommand, because it doesn't works actually)

This commit is contained in:
Dmitry Khomutov 2017-02-04 17:34:19 +07:00
commit 0a4636a379
No known key found for this signature in database
GPG key ID: 7EB36C9576F9ECB9
22 changed files with 198 additions and 695 deletions

View file

@ -61,20 +61,20 @@ class CreateAdminCommand extends Command
/** @var $helper QuestionHelper */
$helper = $this->getHelperSet()->get('question');
$question = new Question(Lang::get('enter_email'));
$question = new Question('Admin email: ');
$question->setValidator(function ($answer) {
if (!filter_var($answer, FILTER_VALIDATE_EMAIL)) {
throw new \InvalidArgumentException(Lang::get('must_be_valid_email'));
throw new \InvalidArgumentException('Must be a valid email address.');
}
return $answer;
});
$adminEmail = $helper->ask($input, $output, $question);
$question = new Question(Lang::get('enter_name'));
$question = new Question('Admin name: ');
$adminName = $helper->ask($input, $output, $question);
$question = new Question(Lang::get('enter_password'));
$question = new Question('Admin password: ');
$question->setHidden(true);
$question->setHiddenFallback(false);
@ -82,9 +82,9 @@ class CreateAdminCommand extends Command
try {
$userService->createUser($adminName, $adminEmail, $adminPass, true);
$output->writeln(Lang::get('user_created'));
$output->writeln('<info>User account created!</info>');
} catch (\Exception $e) {
$output->writeln(sprintf('<error>%s</error>', Lang::get('failed_to_create')));
$output->writeln(sprintf('<error>%s</error>', 'PHP Censor failed to create your admin account.'));
$output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
}
}