本文整理匯總了PHP中Symfony\Component\Console\Question\Question::setHiddenFallback方法的典型用法代碼示例。如果您正苦於以下問題:PHP Question::setHiddenFallback方法的具體用法?PHP Question::setHiddenFallback怎麽用?PHP Question::setHiddenFallback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Console\Question\Question
的用法示例。
在下文中一共展示了Question::setHiddenFallback方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: execute
/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int|null|void
*/
public function execute(InputInterface $input, OutputInterface $output)
{
parent::bootstrapProcessWire($output);
$name = $input->getArgument('name');
$email = $input->getOption('email');
$pass = $input->getOption('password');
$roles = explode(",", $input->getOption('roles'));
$helper = $this->getHelper('question');
if (!$email) {
$question = new Question('Please enter a email address : ', 'email');
$email = $helper->ask($input, $output, $question);
}
if (!$pass) {
$question = new Question('Please enter a password : ', 'password');
$question->setHidden(true);
$question->setHiddenFallback(false);
$pass = $helper->ask($input, $output, $question);
}
if (!\ProcessWire\wire("pages")->get("name={$name}") instanceof \ProcessWire\NullPage) {
$output->writeln("<error>User '{$name}' already exists!</error>");
exit(1);
}
$user = $this->createUser($email, $name, $this->userContainer, $pass);
$user->save();
if ($input->getOption('roles')) {
$this->attachRolesToUser($name, $roles, $output);
}
if ($pass) {
$output->writeln("<info>User '{$name}' created successfully!</info>");
} else {
$output->writeln("<info>User '{$name}' created successfully! Please do not forget to set a password.</info>");
}
}
示例2: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
/** @var WardenSetupService $wardenSetupService */
$wardenSetupService = $this->getContainer()->get('warden_setup');
/** @var UserProviderService $userProviderService */
$userProviderService = $this->getContainer()->get('user_provider');
if ($userProviderService->isSetup() && !$input->getOption('regenerate')) {
$output->writeln('Warden username and password is already setup - check the README file if you need to regenerate.');
return;
}
$helper = $this->getHelper('question');
$usernameQuestion = new Question('Please enter the admin username [admin]: ', 'admin');
$username = $helper->ask($input, $output, $usernameQuestion);
$passwordQuestion = new Question('Please enter the admin password (minimum of 8 characters): ', '');
$passwordQuestion->setValidator(function ($value) {
if (trim($value) == '') {
throw new \Exception('The password can not be empty');
}
if (strlen($value) < 8) {
throw new \Exception('Password provided is too short - must be minimum of 8 characters');
}
return $value;
});
$passwordQuestion->setMaxAttempts(3);
$passwordQuestion->setHidden(TRUE);
$passwordQuestion->setHiddenFallback(FALSE);
$password = $helper->ask($input, $output, $passwordQuestion);
$output->writeln(' - Setting up the password file ...');
$userProviderService->generateLoginFile($username, $password);
$output->writeln(' - Setting up the CSS file ...');
$wardenSetupService->generateCSSFile();
$output->writeln('Warden installation complete.');
}
示例3: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
/** @var QuestionHelper $questionHelper */
$questionHelper = $this->getHelper('question');
$usernameQuestion = new Question('E-mail: ');
$usernameQuestion->setValidator(function ($value) {
if (trim($value) === '') {
throw new \Exception('E-mail can not be empty');
}
if (!Validators::isEmail($value)) {
throw new \Exception('E-mail is not valid');
}
return $value;
});
$passwordQuestion = new Question('Password: ');
$passwordQuestion->setValidator(function ($value) {
if (trim($value) === '') {
throw new \Exception('The password can not be empty');
}
return $value;
});
$passwordQuestion->setHidden(TRUE);
$passwordQuestion->setHiddenFallback(FALSE);
$username = $questionHelper->ask($input, $output, $usernameQuestion);
$password = $questionHelper->ask($input, $output, $passwordQuestion);
$name = $questionHelper->ask($input, $output, new Question('Name: '));
$user = $this->userFacade->add($username, $password, $name);
$output->writeln('User ' . $user->getEmail() . ' was successfully created!');
}
示例4: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
if ($input->getOption("password")) {
$password = $input->getOption("password");
} else {
$question = new Question('Password: ');
$question->setHidden(true);
$question->setHiddenFallback(false);
$helper = $this->getHelper('question');
$password = $helper->ask($input, $output, $question);
}
$server = new Server\Database\Mysql();
$server->setHostname($input->getArgument("host"));
$server->setUser("provisioning");
$server->setPassword($this->createPassword());
$server->setDatabase("provisioning");
$server->setMode($input->getArgument("mode"));
$server->setType($input->getArgument("type"));
$server->setActive(false);
// convert errors to PDOExceptions
$options = [\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION];
$dsn = sprintf("mysql:host=%s;port=%s;charset=utf8", $server->getHostname(), 3306);
$pdo = new \PDO($dsn, $input->getArgument("user"), $password, $options);
$pdo->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
$pdo->exec("SET NAMES utf8;");
$pdo->exec("CREATE USER '{$server->getUser()}'@'%' IDENTIFIED BY '{$server->getPassword()}';");
$pdo->exec("GRANT CREATE, DROP, GRANT OPTION, LOCK TABLES, REFERENCES, EVENT, ALTER, DELETE, INDEX, INSERT, SELECT, UPDATE, CREATE TEMPORARY TABLES, TRIGGER, CREATE VIEW, SHOW VIEW, ALTER ROUTINE, CREATE ROUTINE, EXECUTE, CREATE USER, PROCESS, RELOAD, REPLICATION CLIENT, REPLICATION SLAVE, SHOW DATABASES, USAGE ON *.* TO '{$server->getUser()}' WITH GRANT OPTION;");
$pdo->exec("CREATE DATABASE {$server->getDatabase()} DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;");
// Write to DB
$entityManager = $this->getProvisioningServer("mysql")->getEntityManager();
$entityManager->persist($server);
$entityManager->flush();
$table = $this->getMySqlServersTable([$server], $output);
$table->render();
}
示例5: execute
/**
* Execute the command
*
* @param InputInterface $input
* @param OutputInterface $output
*
* @return void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$db = $input->getOption('db');
if (empty($db)) {
throw new \InvalidArgumentException('You must define the database name with --db');
}
$password = $input->getOption('password');
if (is_null($password)) {
$helper = $this->getHelper('question');
$question = new Question('Password: ');
$question->setHidden(true);
$question->setHiddenFallback(false);
$password = $helper->ask($input, $output, $question);
}
try {
$pdo = new \PDO("mysql:dbname={$db};host=" . $input->getOption('host'), $input->getOption('user'), $password);
} catch (\Exception $e) {
throw new \RuntimeException("Can't connect to the database. Check your credentials");
}
$writer = new \Inet\Neuralyzer\Configuration\Writer();
$ignoreFields = $input->getOption('ignore-field');
$writer->protectCols($input->getOption('protect'));
// Override the protection if fields are defined
if (!empty($ignoreFields)) {
$writer->protectCols(true);
$writer->setProtectedCols($ignoreFields);
}
$writer->setIgnoredTables($input->getOption('ignore-table'));
$data = $writer->generateConfFromDB($pdo, new \Inet\Neuralyzer\Guesser());
$writer->save($data, $input->getOption('file'));
$output->writeln('<comment>Configuration written to ' . $input->getOption('file') . '</comment>');
}
示例6: doRun
public function doRun(InputInterface $input, OutputInterface $output)
{
$password = getenv('VAULT_PASSWORD');
$tries = 0;
while (!$password) {
$question = new Question('Vault password: ', null);
$question->setHidden(true);
$question->setHiddenFallback(false);
$helperSet = $this->getHelperSet();
$helper = $helperSet->get('question');
$password = $helper->ask($input, $output, $question);
}
$this->vault = new Vault($password, $output);
// Defaults
$this->vault->setStoragePath(getcwd() . '/vault');
$this->vault->setWorkPath(getcwd() . '/secure');
$this->vault->verify();
// Load droid.yml
$filename = $this->getVaultFilename();
if ($filename && file_exists($filename)) {
$loader = new JsonLoader();
$loader->load($vault, $filename);
} else {
}
return parent::doRun($input, $output);
}
示例7: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
if ($input->getOption("password")) {
$password = $input->getOption("password");
} else {
$question = new Question('Password: ');
$question->setHidden(true);
$question->setHiddenFallback(false);
$helper = $this->getHelper('question');
$password = $helper->ask($input, $output, $question);
}
$server = new Server\Database\Redshift();
$server->setHostname($input->getArgument("hostname"));
$server->setConnectionId($input->getArgument("connectionId"));
$server->setUser("provisioning");
$server->setPassword($this->createPassword());
$server->setDatabase("provisioning");
$server->setMode("active");
$server->setActive(false);
// convert errors to PDOExceptions
$options = [\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, \PDO::ATTR_EMULATE_PREPARES => false];
$dsn = "pgsql:host={$server->getHostname()};port=5439;dbname={$input->getArgument("database")}";
$pdo = new \PDO($dsn, $input->getArgument("user"), $password, $options);
$pdo->exec("CREATE USER {$server->getUser()} CREATEUSER PASSWORD '{$server->getPassword()}';");
$pdo->exec("CREATE DATABASE {$server->getDatabase()};");
$pdo->exec("REVOKE ALL PRIVILEGES ON SCHEMA public FROM PUBLIC;");
// Write to DB
$entityManager = $this->getProvisioningServer("redshift")->getEntityManager();
$entityManager->persist($server);
$entityManager->flush();
$table = $this->getRedshiftServersTable([$server], $output);
$table->render();
}
示例8: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$login = $input->getArgument("login");
$helper = $this->getHelper('question');
$question = new Question("Unix password for « {$login} » : ");
$question->setHidden(true);
$question->setHiddenFallback(false);
$password = $input->getArgument("password") ? $input->getArgument("password") : $helper->ask($input, $output, $question);
$blih = new Blih($login, $password);
$blihRepositoriesResponse = $blih->repository()->all();
if ($blihRepositoriesResponse->code == 200) {
$user = $this->getUserOrCreateIt($login);
$repositoryNames = array_keys(get_object_vars($blihRepositoriesResponse->body->repositories));
foreach ($repositoryNames as $repositoryName) {
$output->writeln("> Repository « {$login}/{$repositoryName} »");
$repository = $this->getRepoOrCreateIt($user, $repositoryName);
$aclResponse = $blih->repository($repositoryName)->acl()->get();
if ($aclResponse->code == 200) {
$acls = get_object_vars($aclResponse->body);
foreach ($acls as $aclLogin => $acl) {
$output->writeln(" ACL for « {$aclLogin} »: {$acl}");
$aclUser = $this->getUserOrCreateIt($aclLogin);
$repositoryACL = $this->getACLOrCreateIt($aclUser, $repository);
$repositoryACL->setR(strpos($acl, "r") !== false);
$repositoryACL->setW(strpos($acl, "w") !== false);
$repositoryACL->setA(strpos($acl, "a") !== false);
$this->getContainer()->get("doctrine")->getManager()->persist($repositoryACL);
}
}
$output->writeln("");
$this->getContainer()->get("doctrine")->getManager()->persist($repository);
$this->getContainer()->get("doctrine")->getManager()->flush();
}
}
}
示例9: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
if ($input->getOption("password")) {
$password = $input->getOption("password");
} else {
$question = new Question('Password: ');
$question->setHidden(true);
$question->setHiddenFallback(false);
$helper = $this->getHelper('question');
$password = $helper->ask($input, $output, $question);
}
$server = new Server\Database\Redshift();
$server->setHostname($input->getArgument("host"));
$server->setConnectionId($input->getArgument("connectionId"));
$server->setUser($input->getArgument("user"));
$server->setPassword($password);
$server->setDatabase($input->getArgument("database"));
$server->setMode("active");
$server->setActive(false);
// Write to DB
$entityManager = $this->getProvisioningServer("redshift")->getEntityManager();
$entityManager->persist($server);
$entityManager->flush();
$table = $this->getRedshiftServersTable([$server], $output);
$table->render();
}
示例10: secret
/**
* Ask the user the given secret question.
*
* @param string $question
* @return string
*/
public function secret($question)
{
$question = '<comment>' . $question . '</comment> ';
$question = new Question($question);
$question->setHidden(true);
$question->setHiddenFallback(false);
return $this->getHelperSet()->get('question')->ask($this->input, $this->output, $question);
}
示例11: askForPassword
private function askForPassword()
{
$helper = $this->getHelper('question');
$question = new Question('What is the new user\'s password: ');
$question->setHidden(true);
$question->setHiddenFallback(false);
return $helper->ask($this->input, $this->output, $question);
}
示例12: askHiddenResponse
/**
* @param $message
* @return string
*/
public function askHiddenResponse($message)
{
$this->clearLine();
$this->output->writeln("\n");
$question = new Question('<question>' . $message . '</question> ');
$question->setHidden(true);
$question->setHiddenFallback(false);
$var = $this->dialog->ask($this->input, $this->output, $question);
return $var;
}
示例13: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$SafeController = new SafeController();
$safeName = $input->getArgument('safe');
if (empty($safeName)) {
$safeNames = $SafeController->getSafeNames();
$helper = $this->getHelper('question');
$question = new ChoiceQuestion('<question>Please select the safe for this secret:</question> ', $safeNames);
$safeName = $helper->ask($input, $output, $question);
}
if (empty($safeName)) {
throw new \Exception("Invalid safe name");
}
$output->writeln('');
$output->writeln(sprintf("<info>Using safe '%s'... </info>", $safeName));
$keyName = $input->getArgument('key');
if (empty($keyName)) {
$helper = $this->getHelper('question');
$question = new Question('<question>Please enter the key name for this secret :</question> ');
$keyName = $helper->ask($input, $output, $question);
}
if (empty($keyName)) {
throw new \Exception("Invalid key name");
}
$value = $input->getArgument('value');
if (empty($value)) {
$helper = $this->getHelper('question');
$question = new Question('<question>Please enter the value for this secret (output hidden):</question> ');
$question->setHidden(true);
$question->setHiddenFallback(false);
$value = $helper->ask($input, $output, $question);
}
if (empty($value) && !file_exists($value)) {
throw new \Exception("Invalid value");
}
if (file_exists($value)) {
$value = file_get_contents($value);
}
$output->writeln('');
$output->write(sprintf("Creating secret '%s'... ", $keyName));
$SecretController = new SecretController();
try {
$safe = $SafeController->view($safeName);
$SecretController->create($safe, $keyName, $value);
} catch (\Exception $e) {
$output->writeln('<error>FAILED</error>');
$output->writeln('');
$output->writeln('<error>' . $e->getMessage() . '</error>');
return;
}
$output->writeln('<info>DONE</info>');
$output->writeln('');
}
示例14: requestSlackCredentials
protected function requestSlackCredentials(InputInterface $input, OutputInterface $output)
{
$helper = $this->getHelper('question');
$output->writeln('<info>Please sign in to Slack to continue. Your username and password are not stored.</info>');
$emailQuestion = new Question('Email: ');
$email = $helper->ask($input, $output, $emailQuestion);
$passwordQuestion = new Question('Password: ');
$passwordQuestion->setHidden(true);
$passwordQuestion->setHiddenFallback(false);
$password = $helper->ask($input, $output, $passwordQuestion);
return array($email, $password);
}
示例15: ask
/**
* Ask a question
*
* @param string $question Question to ask
* @param mixed $default Default value
* @param bool $hidden Hide response
* @param bool $required User input is required
* @return mixed
*/
public function ask($question, $default = null, $hidden = false, $required = true)
{
$helper = $this->getHelper('question');
$q = new Question($question, $default);
if ($hidden) {
$q->setHidden(true);
$q->setHiddenFallback(false);
}
if ($required) {
$q->setValidator([$this, 'assertNotEmpty']);
$q->setMaxAttempts(2);
}
return $helper->ask($this->input, $this->output, $q);
}