当前位置: 首页>>代码示例>>PHP>>正文


PHP Question::setHidden方法代码示例

本文整理汇总了PHP中Symfony\Component\Console\Question\Question::setHidden方法的典型用法代码示例。如果您正苦于以下问题:PHP Question::setHidden方法的具体用法?PHP Question::setHidden怎么用?PHP Question::setHidden使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Console\Question\Question的用法示例。


在下文中一共展示了Question::setHidden方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: informAboutStructure

 /**
  * Informs the display about the structure of a Field.
  * 
  * Each time the Field structure changes for some reason, this method shall
  * be called.
  *
  * @param \Feeld\Display\DisplayDataSourceInterface $field
  * @throws Exception
  */
 public function informAboutStructure(\Feeld\Display\DisplayDataSourceInterface $field)
 {
     parent::informAboutStructure($field);
     $this->field = $field;
     if ($field instanceof \Feeld\Field\Entry) {
         $this->symfonyQuestion = new SymfonyQuestion((string) $this, $field instanceof DefaultValueInterface && $field->hasDefault() ? $field->getDefault() : null);
     } elseif ($field instanceof \Feeld\Field\Select) {
         $this->symfonyQuestion = new \Symfony\Component\Console\Question\ChoiceQuestion((string) $this, array_keys($field->getOptions()), $field instanceof DefaultValueInterface && $field->hasDefault() ? $field->getDefault() : null);
         if ($field instanceof \Feeld\Field\CommonProperties\MultipleChoiceInterface && $field->isMultipleChoice()) {
             $field->symfonyQuestion->setMultiselect(true);
         }
     } elseif ($field instanceof \Feeld\Field\CloakedEntry) {
         $this->symfonyQuestion = new SymfonyQuestion((string) $this, $field instanceof DefaultValueInterface && $field->hasDefault() ? $field->getDefault() : null);
         $this->symfonyQuestion->setHidden(true);
     } elseif ($field instanceof \Feeld\Field\Constant) {
         throw new Exception('Constants are currently not supported in SymfonyConsoleDisplay');
     } elseif ($field instanceof \Feeld\Field\Checkbox) {
         $this->symfonyQuestion = new \Symfony\Component\Console\Question\ConfirmationQuestion((string) $this, $field instanceof DefaultValueInterface && $field->hasDefault() ? $field->getDefault() : true, '/^' . strtolower(substr($this->getTrueOption(), 0, 1)) . '/i');
     }
     $this->symfonyQuestion->setNormalizer(function ($value) {
         return $this->field->getSanitizer()->filter($value);
     });
     $this->symfonyQuestion->setValidator(function ($value) {
         $validationResultSet = $this->field->validateValue($value);
         if ($validationResultSet->hasErrors()) {
             $this->field->clearValidationResult();
             throw new \Exception(implode(PHP_EOL, $validationResultSet->getErrorMessages()));
         }
         return $this->field->getFilteredValue();
     });
     $this->symfonyQuestion->setMaxAttempts(null);
 }
开发者ID:broeser,项目名称:feeld,代码行数:41,代码来源:SymfonyConsoleDisplay.php

示例2: 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>");
     }
 }
开发者ID:wireshell,项目名称:wireshell,代码行数:38,代码来源:UserCreateCommand.php

示例3: 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>');
 }
开发者ID:inetprocess,项目名称:neuralyzer,代码行数:40,代码来源:ConfigGenerateCommand.php

示例4: execute

 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $helper = $this->getHelper('question');
     $username = $helper->ask($input, $output, new Question('Username: '));
     if (!$username) {
         $output->writeln("<error>Invalid username</error>");
         return;
     }
     $pw_question = new Question('Password: ');
     $pw_question->setHidden(true);
     $password = $helper->ask($input, $output, $pw_question);
     if (!$password) {
         $output->writeln("<error>Invalid password</error>");
         return;
     }
     $roles = $this->getRoles(null, $input, $output);
     $output->writeln('Username: <info>' . $username . '</info>');
     $output->writeln('Roles:    <info>' . implode(', ', $roles) . '</info>');
     $this->showRoleWarnings($roles, $output);
     if (!$helper->ask($input, $output, new ConfirmationQuestion('Create user? [y/N]: ', false))) {
         return;
     }
     $provider = $this->getContainer()->get('orm.user_provider');
     $provider->createUser($username, $password, $roles);
     $output->writeln("Created new user");
 }
开发者ID:bravo3,项目名称:orm-bundle,代码行数:31,代码来源:CreateUserCommand.php

示例5: interact

 /**
  * @see Command
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $questions = array();
     if (!$input->getArgument('username')) {
         $question = new Question('Please give the username:');
         $question->setValidator(function ($username) {
             if (empty($username)) {
                 throw new \Exception('Username can not be empty');
             }
             return $username;
         });
         $questions['username'] = $question;
     }
     if (!$input->getArgument('password')) {
         $question = new Question('Please enter the new password:');
         $question->setValidator(function ($password) {
             if (empty($password)) {
                 throw new \Exception('Password can not be empty');
             }
             return $password;
         });
         $question->setHidden(true);
         $questions['password'] = $question;
     }
     foreach ($questions as $name => $question) {
         $answer = $this->getHelper('question')->ask($input, $output, $question);
         $input->setArgument($name, $answer);
     }
 }
开发者ID:ismailbaskin,项目名称:FOSUserBundle,代码行数:32,代码来源:ChangePasswordCommand.php

示例6: handle

 public function handle(InputInterface $input, OutputInterface $output)
 {
     $data = [];
     $helper = $this->command->getHelper('question');
     $data['jiraHost'] = $helper->ask($input, $output, new Question('Domain (yourdomain.atlassian.net): ', false));
     $data['jiraUser'] = $helper->ask($input, $output, new Question('Username: ', false));
     $passwordQuestion = new Question('Password: ', false);
     $passwordQuestion->setHidden(true)->setHiddenFallback(false);
     $password = $helper->ask($input, $output, $passwordQuestion);
     //        $passwordQuestion2 = new Question('Confirm Password: ', false);
     //        $passwordQuestion2->setHidden(true)->setHiddenFallback(false);
     //        $password2 = $helper->ask($input, $output, $passwordQuestion2);
     //        if (empty($password) || empty($password2)) {
     //            throw new \RuntimeException('Password cannot be blank');
     //        }
     //
     //        if ($password !== $password2) {
     //            throw new \RuntimeException('Passwords must match.');
     //        }
     $data['jiraPassword'] = $password;
     if ($this->config->write($data) !== false) {
         $output->writeln('Config written to file: ' . $this->config->filePath());
     } else {
         $output->writeln('Nothing written..');
     }
 }
开发者ID:humweb,项目名称:slackpipe,代码行数:26,代码来源:SetupCommand.php

示例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\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();
 }
开发者ID:keboola,项目名称:provisioning-bundle,代码行数:35,代码来源:InitMysqlServerCommand.php

示例8: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $helper = $this->getHelper('question');
     $question = new Question('Please enter app\'s shared secret: ');
     $question->setValidator(function ($answer) {
         if (empty($answer)) {
             throw new RuntimeException('Shared secret must be provided');
         }
         return $answer;
     });
     $question->setHidden(true);
     $question->setMaxAttempts(2);
     $sharedSecret = $helper->ask($input, $output, $question);
     $receiptFile = __DIR__ . '/../../../tmp/receipt';
     if (!is_file(realpath($receiptFile))) {
         throw new RuntimeException(sprintf('Create a file with receipt data here %s', $receiptFile));
     }
     $receiptData = file_get_contents($receiptFile);
     if (empty($receiptData)) {
         throw new RuntimeException(sprintf('Put receipt data here %s', $receiptFile));
     }
     $validator = new Validator();
     $validator->setSecret($sharedSecret);
     $validator->setReceiptData($receiptData);
     $response = $validator->validate();
     var_dump($response);
 }
开发者ID:plehatron,项目名称:receipt-validation,代码行数:27,代码来源:VerifyCommand.php

示例9: 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!');
 }
开发者ID:wodcz,项目名称:sandbox,代码行数:29,代码来源:CreateUser.php

示例10: interact

 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     if (null !== $this->getContainer()->getParameter('installed')) {
         throw new ApplicationInstalledException();
     }
     $currencies = Intl::getCurrencyBundle()->getCurrencyNames();
     $locales = Intl::getLocaleBundle()->getLocaleNames();
     $localeQuestion = new Question('<question>Please enter a locale:</question> ');
     $localeQuestion->setAutocompleterValues($locales);
     $currencyQuestion = new Question('<question>Please enter a currency:</question> ');
     $currencyQuestion->setAutocompleterValues($currencies);
     $passwordQuestion = new Question('<question>Please enter a password for the admin account:</question> ');
     $passwordQuestion->setHidden(true);
     $options = array('database-user' => new Question('<question>Please enter your database user name:</question> '), 'admin-username' => new Question('<question>Please enter a username for the admin account:</question> '), 'admin-password' => $passwordQuestion, 'admin-email' => new Question('<question>Please enter an email address for the admin account:</question> '), 'locale' => $localeQuestion, 'currency' => $currencyQuestion);
     /** @var QuestionHelper $dialog */
     $dialog = $this->getHelper('question');
     /** @var Question $question */
     foreach ($options as $option => $question) {
         if (null === $input->getOption($option)) {
             $value = null;
             while (empty($value)) {
                 $value = $dialog->ask($input, $output, $question);
                 if ($values = $question->getAutocompleterValues()) {
                     $value = array_search($value, $values);
                 }
             }
             $input->setOption($option, $value);
         }
     }
 }
开发者ID:Codixis,项目名称:CSBill,代码行数:33,代码来源:InstallCommand.php

示例11: 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);
 }
开发者ID:linkorb,项目名称:vault,代码行数:26,代码来源:Application.php

示例12: 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();
 }
开发者ID:keboola,项目名称:provisioning-bundle,代码行数:33,代码来源:InitRedshiftServerCommand.php

示例13: 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.');
 }
开发者ID:TWEagle,项目名称:warden,代码行数:33,代码来源:InstallCommand.php

示例14: execute

 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $helper = $this->getHelper('question');
     $provider = $this->getContainer()->get('orm.user_provider');
     /** @var User $user */
     $user = $provider->loadUserByUsername($input->getArgument('username'));
     $pw_question = new Question('New password: ');
     $pw_question->setHidden(true);
     $password = $helper->ask($input, $output, $pw_question);
     if (!$password) {
         $output->writeln("<error>Invalid password</error>");
         return;
     }
     $roles = $this->getRoles($user->getRoles(), $input, $output);
     $output->writeln('Username: <info>' . $user->getUsername() . '</info>');
     $output->writeln('Roles:    <info>' . implode(', ', $roles) . '</info>');
     $this->showRoleWarnings($roles, $output);
     if (!$helper->ask($input, $output, new ConfirmationQuestion('Update user? [y/N]: ', false))) {
         return;
     }
     $user->setRoles($roles);
     $provider = $this->getContainer()->get('orm.user_provider');
     $provider->updateUserCredentials($user, $password);
     $output->writeln("User updated");
 }
开发者ID:bravo3,项目名称:orm-bundle,代码行数:30,代码来源:UpdateUserCommand.php

示例15: secret

 protected function secret($question)
 {
     $helper = $this->helperSet->get('question');
     $question = new Question("<question>{$question}</question> ");
     $question->setHidden(true)->setHiddenFallback(true);
     return $helper->ask($this->input, $this->output, $question);
 }
开发者ID:fluxbb,项目名称:installer,代码行数:7,代码来源:UserDataProvider.php


注:本文中的Symfony\Component\Console\Question\Question::setHidden方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。