protected function execute(InputInterface $input, OutputInterface $output)
    {
        $userService = new UserService($this->userStore);

        /** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */
        $dialog = $this->getHelperSet()->get('dialog');

        // Function to validate mail address.
        $mailValidator = function ($answer) {
            if (!filter_var($answer, FILTER_VALIDATE_EMAIL)) {
                throw new \InvalidArgumentException(Lang::get('must_be_valid_email'));
            }

            return $answer;
        };

        $adminEmail = $dialog->askAndValidate($output, Lang::get('enter_email'), $mailValidator, false);
        $adminName = $dialog->ask($output, Lang::get('enter_name'));
        $adminPass = $dialog->askHiddenResponse($output, Lang::get('enter_password'));

        try {
            $userService->createUser($adminName, $adminEmail, $adminPass, true);
            $output->writeln(Lang::get('user_created'));
        } catch (\Exception $e) {
            $output->writeln(sprintf('<error>%s</error>', Lang::get('failed_to_create')));
            $output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
        }
    }
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $userService = new UserService($this->userStore);

        /** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */
        $dialog = $this->getHelperSet()->get('dialog');

        // Function to validate mail address.
        $mailValidator = function ($answer) {
            if (!filter_var($answer, FILTER_VALIDATE_EMAIL)) {
                throw new \InvalidArgumentException(Lang::get('must_be_valid_email'));
            }

            return $answer;
        };

        $adminEmail = $dialog->askAndValidate($output, Lang::get('enter_email'), $mailValidator, false);
        $adminName = $dialog->ask($output, Lang::get('enter_name'));
        $adminPass = $dialog->askHiddenResponse($output, Lang::get('enter_password'));

        try {
            $userService->createUser($adminName, $adminEmail, $adminPass, true);
            $output->writeln(Lang::get('user_created'));
        } catch (\Exception $e) {
            $output->writeln(sprintf('<error>%s</error>', Lang::get('failed_to_create')));
            $output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
        }
    }
protected function execute ( InputInterface $ input , OutputInterface $ output ) { $ userService = new UserService ( $ this -> userStore ) ; /** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */ $ dialog = $ this -> getHelperSet ( ) -> get ( 'dialog' ) ; // Function to validate mail address. $ mailValidator = function ( $ answer ) { if ( ! filter_var ( $ answer , FILTER_VALIDATE_EMAIL ) ) { throw new \ InvalidArgumentException ( Lang :: get ( 'must_be_valid_email' ) ) ; } return $ answer ; } ; $ adminEmail = $ dialog -> askAndValidate ( $ output , Lang :: get ( 'enter_email' ) , $ mailValidator , false ) ; $ adminName = $ dialog -> ask ( $ output , Lang :: get ( 'enter_name' ) ) ; $ adminPass = $ dialog -> askHiddenResponse ( $ output , Lang :: get ( 'enter_password' ) ) ; try { $ userService -> createUser ( $ adminName , $ adminEmail , $ adminPass , true ) ; $ output -> writeln ( Lang :: get ( 'user_created' ) ) ; } catch ( \ Exception $ e ) { $ output -> writeln ( sprintf ( '<error>%s</error>' , Lang :: get ( 'failed_to_create' ) ) ) ; $ output -> writeln ( sprintf ( '<error>%s</error>' , $ e -> getMessage ( ) ) ) ; } }
Creates an admin user in the existing PHPCI database

{@inheritDoc}
Creates an admin user in the existing PHPCI database