當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Question::setAutocompleterValues方法代碼示例

本文整理匯總了PHP中Symfony\Component\Console\Question\Question::setAutocompleterValues方法的典型用法代碼示例。如果您正苦於以下問題:PHP Question::setAutocompleterValues方法的具體用法?PHP Question::setAutocompleterValues怎麽用?PHP Question::setAutocompleterValues使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Console\Question\Question的用法示例。


在下文中一共展示了Question::setAutocompleterValues方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: doIt

 /**
  * @param   InputInterface            $input  An InputInterface instance
  * @param   OutputInterface           $output An OutputInterface instance
  * @param   CollectionFinderInterface $finder The finder
  * @param   string                    $entity The entity name
  *
  * @return  void
  */
 protected function doIt(InputInterface $input, OutputInterface $output, $finder, $entity)
 {
     $count = 0;
     $force = $input->getOption('no-interaction');
     $repository = $this->repositoryFactory->forEntity($entity);
     $idAccessorRegistry = $this->repositoryFactory->getIdAccessorRegistry();
     foreach ($this->getRecords($finder) as $record) {
         $id = $idAccessorRegistry->getEntityId($record);
         $choice = 'no';
         if (!$force) {
             $question = new Question("Delete {$entity} #{$id} (yes,No,all)? ", 'no');
             $question->setAutocompleterValues(['yes', 'no', 'all']);
             $choice = $this->ask($input, $output, $question);
             if ($choice == 'all') {
                 $force = true;
             }
         }
         if ($force || $choice == 'yes') {
             $repository->remove($record);
             $count++;
         }
     }
     $repository->commit();
     $this->writeln($output, "Deleted {$count} {$entity} item(s).");
 }
開發者ID:nibra,項目名稱:joomla-pythagoras,代碼行數:33,代碼來源:DeleteCommand.php

示例2: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $em = $this->getContainer()->get('doctrine')->getManager();
     $helper = $this->getHelper('question');
     $output->writeln("\n<question>                                      ");
     $output->writeln(' Welcome to the Fbeen slug generator. ');
     $output->writeln("                                      </question>\n");
     $entityName = $input->getArgument('entity');
     if (!$entityName) {
         $output->writeln('This command helps you to update slugs on an entire table.');
         $output->writeln('First, you need to give the entity for which you want to generate the slugs.');
         $output->writeln("\nYou must use the shortcut notation like <comment>AcmeBlogBundle:Post</comment>.\n");
         $question = new Question('<info>The Entity shortcut name: </info>');
         $question->setValidator(array('Sensio\\Bundle\\GeneratorBundle\\Command\\Validators', 'validateEntityName'));
         $autocompleter = new EntitiesAutoCompleter($em);
         $autocompleteEntities = $autocompleter->getSuggestions();
         $question->setAutocompleterValues($autocompleteEntities);
         $entityName = $helper->ask($input, $output, $question);
     }
     $entities = $em->getRepository($entityName)->findAll();
     $question = new ConfirmationQuestion('<info>Continue generating slugs for ' . $entityName . '</info> [<comment>no</comment>]? ', false);
     if (!$helper->ask($input, $output, $question)) {
         return;
     }
     $output->writeln("\nGenerating the slugs...");
     $slugupdater = new SlugUpdater();
     foreach ($entities as $entity) {
         $slugupdater->preUpdate(new LifecycleEventArgs($entity, $em));
         $em->flush();
     }
     $output->writeln("\nDone!\n");
 }
開發者ID:fbeen,項目名稱:uniqueslugbundle,代碼行數:32,代碼來源:SlugCommand.php

示例3: interact

 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     // Start question helper
     $questionHelper = $this->getQuestionHelper();
     $questionHelper->writeSection($output, 'Welcome to the united CRUD generator!');
     // get entity
     $entity = $input->getOption('entity');
     $question = new Question($questionHelper->getQuestion('Entity', $entity), $entity);
     $question->setValidator(function ($answer) {
         return Validators::validateEntityName($answer);
     });
     $complete = new EntitiesAutoCompleter($this->getContainer()->get('doctrine')->getManager());
     $completeEntities = $complete->getSuggestions();
     $question->setAutocompleterValues($completeEntities);
     $entity = $questionHelper->ask($input, $output, $question);
     $input->setOption('entity', $entity);
     // get bundle
     $destinationBundle = $input->getOption('bundle');
     $question = new Question($questionHelper->getQuestion('Destination bundle', $destinationBundle), $destinationBundle);
     $question->setValidator(function ($answer) {
         return Validators::validateBundleName($answer);
     });
     $question->setAutocompleterValues($this->getBundleSuggestions());
     $destinationBundle = $questionHelper->ask($input, $output, $question);
     $input->setOption('bundle', $destinationBundle);
 }
開發者ID:franzwilding,項目名稱:UnitedBundle,代碼行數:29,代碼來源:UnitedGenerateCrudCommand.php

示例4: askForNamespace

 /**
  * Asks for the namespace and sets it on the InputInterface as the 'namespace' option, if this option is not set yet.
  *
  * @param array $text What you want printed before the namespace is asked.
  *
  * @return string The namespace. But it's also been set on the InputInterface.
  */
 public function askForNamespace(array $text = null)
 {
     $namespace = $this->input->hasOption('namespace') ? $this->input->getOption('namespace') : null;
     // When the Namespace is filled in return it immediately if valid.
     try {
         if (!is_null($namespace) && !empty($namespace)) {
             Validators::validateBundleNamespace($namespace);
             return $namespace;
         }
     } catch (\Exception $error) {
         $this->writeError(array("Namespace '{$namespace}' is incorrect. Please provide a correct value.", $error->getMessage()));
         exit;
     }
     $ownBundles = $this->getOwnBundles();
     if (count($ownBundles) <= 0) {
         $this->writeError("Looks like you don't have created a bundle for your project, create one first.", true);
     }
     $namespace = '';
     // If we only have 1 or more bundles, we can prefill it.
     if (count($ownBundles) > 0) {
         $namespace = $ownBundles[1]['namespace'] . '/' . $ownBundles[1]['name'];
     }
     $namespaces = $this->getNamespaceAutoComplete($this->kernel);
     if (!is_null($text) && count($text) > 0) {
         $this->output->writeln($text);
     }
     $question = new Question($this->questionHelper->getQuestion('Bundle Namespace', $namespace), $namespace);
     $question->setValidator(array('Sensio\\Bundle\\GeneratorBundle\\Command\\Validators', 'validateBundleNamespace'));
     $question->setAutocompleterValues($namespaces);
     $namespace = $this->questionHelper->ask($this->input, $this->output, $question);
     if ($this->input->hasOption('namespace')) {
         $this->input->setOption('namespace', $namespace);
     }
     return $namespace;
 }
開發者ID:BranchBit,項目名稱:KunstmaanBundlesCMS,代碼行數:42,代碼來源:InputAssistant.php

示例5: 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

示例6: interact

 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $questionHelper = $this->getQuestionHelper();
     $questionHelper->writeSection($output, 'Welcome to the Doctrine2 CRUD generator');
     // namespace
     $output->writeln(array('', 'This command helps you generate CRUD controllers and templates.', '', 'First, you need to give the entity for which you want to generate a CRUD.', 'You can give an entity that does not exist yet and the wizard will help', 'you defining it.', '', 'You must use the shortcut notation like <comment>AcmeBlogBundle:Post</comment>.', ''));
     if ($input->hasArgument('entity') && $input->getArgument('entity') != '') {
         $input->setOption('entity', $input->getArgument('entity'));
     }
     $question = new Question($questionHelper->getQuestion('The Entity shortcut name', $input->getOption('entity')), $input->getOption('entity'));
     $question->setValidator(array('Sensio\\Bundle\\GeneratorBundle\\Command\\Validators', 'validateEntityName'));
     $autocompleter = new EntitiesAutoCompleter($this->getContainer()->get('doctrine')->getManager());
     $autocompleteEntities = $autocompleter->getSuggestions();
     $question->setAutocompleterValues($autocompleteEntities);
     $entity = $questionHelper->ask($input, $output, $question);
     $input->setOption('entity', $entity);
     list($bundle, $entity) = $this->parseShortcutNotation($entity);
     // write?
     $withWrite = 'yes';
     $input->setOption('with-write', $withWrite);
     // format
     $format = 'annotation';
     $input->setOption('format', $format);
     // route prefix
     $prefix = $this->getRoutePrefix($input, $entity);
     $output->writeln(array('', 'Determine the routes prefix (all the routes will be "mounted" under this', 'prefix: /prefix/, /prefix/new, ...).', ''));
     $prefix = $questionHelper->ask($input, $output, new Question($questionHelper->getQuestion('Routes prefix', '/' . $prefix), '/' . $prefix));
     $input->setOption('route-prefix', $prefix);
     // summary
     $output->writeln(array('', $this->getHelper('formatter')->formatBlock('Summary before generation', 'bg=blue;fg=white', true), '', sprintf("You are going to generate a CRUD controller for \"<info>%s:%s</info>\"", $bundle, $entity), sprintf("using the \"<info>%s</info>\" format.", $format), ''));
 }
開發者ID:blacksad12,項目名稱:oliorga,代碼行數:31,代碼來源:GenerateDoctrineCrudCommand.php

示例7: askAndValidate

 /**
  * Asks a question and validates the response.
  *
  * @param  string   $question  The question
  * @param  array    $choices   Autocomplete options
  * @param  function $validator The callback function
  * @param  mixed    $default   The default value
  * @return string
  */
 public function askAndValidate($question, array $choices, $validator, $default = null)
 {
     $question = new Question($question, $default);
     if (count($choices)) {
         $question->setAutocompleterValues($choices);
     }
     $question->setValidator($validator);
     return $this->output->askQuestion($question);
 }
開發者ID:andresnijder,項目名稱:deployer,代碼行數:18,代碼來源:AskAndValidate.php

示例8: interact

 /**
  * Configures the interactive part of the console application
  * @param InputInterface $input The console input object
  * @param OutputInterface $output The console output object
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     if (empty($input->getArgument('issue-key'))) {
         $this->connect($input->getOption('url'), $input->getOption('auth'));
         $question = new Question('Issue key: ');
         $question->setAutocompleterValues(Project::getInstance()->getAllProjectKeys());
         $input->setArgument('issue-key', $this->getHelper('question')->ask($input, $output, $question));
     }
 }
開發者ID:jedi58,項目名稱:jira-integration,代碼行數:14,代碼來源:GetCommand.php

示例9: interact

 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $questionHelper = $this->getQuestionHelper();
     $questionHelper->writeSection($output, 'Welcome to the Doctrine2 CRUD generator');
     // namespace
     $output->writeln(array('', 'This command helps you generate CRUD controllers and templates.', '', 'First, give the name of the existing entity for which you want to generate a CRUD', '(use the shortcut notation like <comment>AcmeBlogBundle:Post</comment>)', ''));
     if ($input->hasArgument('entity') && $input->getArgument('entity') != '') {
         $input->setOption('entity', $input->getArgument('entity'));
     }
     $question = new Question($questionHelper->getQuestion('The Entity shortcut name', $input->getOption('entity')), $input->getOption('entity'));
     $question->setValidator(array('Sensio\\Bundle\\GeneratorBundle\\Command\\Validators', 'validateEntityName'));
     $autocompleter = new EntitiesAutoCompleter($this->getContainer()->get('doctrine')->getManager());
     $autocompleteEntities = $autocompleter->getSuggestions();
     $question->setAutocompleterValues($autocompleteEntities);
     $entity = $questionHelper->ask($input, $output, $question);
     $input->setOption('entity', $entity);
     list($bundle, $entity) = $this->parseShortcutNotation($entity);
     try {
         $entityClass = $this->getContainer()->get('doctrine')->getAliasNamespace($bundle) . '\\' . $entity;
         $metadata = $this->getEntityMetadata($entityClass);
     } catch (\Exception $e) {
         throw new \RuntimeException(sprintf('Entity "%s" does not exist in the "%s" bundle. You may have mistyped the bundle name or maybe the entity doesn\'t exist yet (create it first with the "doctrine:generate:entity" command).', $entity, $bundle));
     }
     // write?
     $withWrite = $input->getOption('with-write') ?: false;
     $output->writeln(array('', 'By default, the generator creates two actions: list and show.', 'You can also ask it to generate "write" actions: new, update, and delete.', ''));
     $question = new ConfirmationQuestion($questionHelper->getQuestion('Do you want to generate the "write" actions', $withWrite ? 'yes' : 'no', '?', $withWrite), $withWrite);
     $withWrite = $questionHelper->ask($input, $output, $question);
     $input->setOption('with-write', $withWrite);
     // format
     $format = $input->getOption('format');
     $output->writeln(array('', 'Determine the format to use for the generated CRUD.', ''));
     $question = new Question($questionHelper->getQuestion('Configuration format (yml, xml, php, or annotation)', $format), $format);
     $question->setValidator(array('Sensio\\Bundle\\GeneratorBundle\\Command\\Validators', 'validateFormat'));
     $format = $questionHelper->ask($input, $output, $question);
     $input->setOption('format', $format);
     // route prefix
     $prefix = $this->getRoutePrefix($input, $entity);
     $output->writeln(array('', 'Determine the routes prefix (all the routes will be "mounted" under this', 'prefix: /prefix/, /prefix/new, ...).', ''));
     $prefix = $questionHelper->ask($input, $output, new Question($questionHelper->getQuestion('Routes prefix', '/' . $prefix), '/' . $prefix));
     $input->setOption('route-prefix', $prefix);
     // controller folder?
     $controllerFolder = $input->getOption('controller-folder') ?: 'src/AppBundle/Controller/';
     $output->writeln(array('', 'By default, the generator creates the controller on Controller namespace.', 'You can also generate it on an subnamespace (Ex: src/AppBundle/Controller/Backend).', ''));
     $question = new Question($questionHelper->getQuestion('Determine the subnamespace you want:', $controllerFolder), $controllerFolder);
     $controllerFolder = $questionHelper->ask($input, $output, $question);
     if ($controllerFolder == 'src/AppBundle/Controller/') {
         $controllerFolder = '';
     }
     $input->setOption('controller-folder', $controllerFolder);
     // summary
     $output->writeln(array('', $this->getHelper('formatter')->formatBlock('Summary before generation', 'bg=blue;fg=white', true), '', sprintf('You are going to generate a CRUD controller for "<info>%s:%s</info>"', $bundle, $entity), sprintf('using the "<info>%s</info>" format.', $format), ''));
 }
開發者ID:a2c,項目名稱:BaconGeneratorBundle,代碼行數:53,代碼來源:CrudDoctrineCommand.php

示例10: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $helper = $this->getHelper('question');
     $output->write(_("Connecting to the Database..."));
     try {
         $db = \FreePBX::Database();
     } catch (\Exception $e) {
         $output->writeln("<error>" . _("Unable to connect to database!") . "</error>");
         return;
     }
     $output->writeln(_("Connected"));
     $driver = $db->getAttribute(\PDO::ATTR_DRIVER_NAME);
     $bundles = array();
     while (true) {
         $question = new Question($driver . '>', '');
         $question->setAutocompleterValues($bundles);
         $answer = $helper->ask($input, $output, $question);
         if (preg_match("/^exit/i", $answer)) {
             exit;
         }
         $bundles[] = $answer;
         try {
             $time_start = microtime(true);
             $ob = $db->query($answer);
             $time_end = microtime(true);
         } catch (\Exception $e) {
             $output->writeln("<error>" . $e->getMessage() . "</error>");
             continue;
         }
         if (!$ob) {
             $output->writeln("<error>" . $db->errorInfo() . "</error>");
             continue;
         }
         //if we get rows back from a query fetch them
         if ($ob->rowCount()) {
             $gotRows = $ob->fetchAll(\PDO::FETCH_ASSOC);
         } else {
             $gotRows = array();
         }
         if (!empty($gotRows)) {
             $rows = array();
             foreach ($gotRows as $row) {
                 $rows[] = array_values($row);
             }
             $table = new Table($output);
             $table->setHeaders(array_keys($gotRows[0]))->setRows($rows);
             $table->render();
             $output->writeln(sprintf(_("%s rows in set (%s sec)"), $ob->rowCount(), round($time_end - $time_start, 2)));
         } else {
             $output->writeln(_("Successfully executed"));
         }
     }
 }
開發者ID:powerpbx,項目名稱:framework,代碼行數:53,代碼來源:Mysql.class.php

示例11: _getQuestion

 /**
  * Gets the question object that is to be asked.
  *
  * The question will either be a ChoiceQuestion, ConfirmationQuestion, or regular Question based on the configuration.
  *
  * @return \Symfony\Component\Console\Question\Question The question to be asked.
  */
 protected function _getQuestion()
 {
     if ($this->_isSelect()) {
         return new ChoiceQuestion($this->_displayQuestion(), $this->_choices, $this->_default);
     }
     if ($this->_isConfirmation()) {
         return new ConfirmationQuestion($this->_displayQuestion(), $this->_default);
     }
     $question = new Question($this->_displayQuestion(), $this->_default);
     $question->setAutocompleterValues($this->_choices);
     return $question;
 }
開發者ID:guywithnose,項目名稱:release-notes,代碼行數:19,代碼來源:Prompt.php

示例12: askAndValidate

 /**
  * Asks a question and validates the response.
  *
  * @param string $question
  * @param array $choices
  * @param callback $validator
  * @param mixed $default
  * @param bool $secret
  *
  * @return string
  */
 public function askAndValidate($question, array $choices, $validator, $default = null, $secret = false)
 {
     $question = new Question($question, $default);
     if ($secret) {
         $question->setHidden(true);
     }
     if (count($choices)) {
         $question->setAutocompleterValues($choices);
     }
     $question->setValidator($validator);
     return $this->getOutput()->askQuestion($question);
 }
開發者ID:rebelinblue,項目名稱:deployer,代碼行數:23,代碼來源:AskAndValidate.php

示例13: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $rootDir = realpath($this->getContainer()->getParameter('kernel.root_dir') . '/..');
     $entities = [];
     $files = glob($rootDir . '/src/AppBundle/Entity/*.php');
     foreach ($files as $file) {
         $entities[] = str_replace('/', '\\', str_replace('.php', '', str_replace($rootDir . '/src/', '', $file)));
     }
     $helper = $this->getHelper('question');
     $question = new Question('<info>Entity name (fully namespace)</info> (ex AppBundle\\Entity\\Post): ');
     $question->setAutocompleterValues($entities);
     $entityName = $helper->ask($input, $output, $question);
     if (empty($entityName)) {
         $output->writeln('<error>Entity name is required</error>');
         return;
     }
     $default = str_replace('\\Entity\\', '\\Form\\', $entityName) . 'Type';
     $question = new Question('<info>Entity name (fully namespace)</info> [' . $default . ']: ', $default);
     $formType = $helper->ask($input, $output, $question);
     $tokens = explode('\\', $entityName);
     $default = end($tokens) . 's';
     $question = new Question('<info>Controller name (without Controller suffix)</info> [' . $default . ']: ', $default);
     $controllerName = $helper->ask($input, $output, $question);
     $default = strtolower($controllerName);
     $question = new Question('<info>Controller route prefix</info> [' . $default . ']: ', $default);
     $routePrefix = $helper->ask($input, $output, $question);
     $default = preg_replace("/[^\\w\\d\\s]/", "_", $routePrefix);
     $question = new Question('<info>Route name prefix</info> [' . $default . ']: ', $default);
     $routeNamePrefix = $helper->ask($input, $output, $question);
     $default = $routePrefix;
     $question = new Question('<info>Template path</info> [' . $default . ']: ', $default);
     $templatePath = $helper->ask($input, $output, $question);
     $params = ['entityName' => $entityName, 'formType' => $formType, 'controllerName' => $controllerName, 'routePrefix' => $routePrefix, 'routeNamePrefix' => $routeNamePrefix, 'templatePath' => $templatePath];
     $builder = new \Mangati\BaseBundle\Builder\CrudControllerBuilder();
     $classContent = $builder->controller($params);
     $filename = $rootDir . '/src/AppBundle/Controller/' . $controllerName . 'Controller.php';
     file_put_contents($filename, $classContent);
     $output->writeln('<info>Generated controller class in </info>' . $filename);
     $baseDir = $rootDir . '/app/Resources/views/' . $templatePath;
     if (!is_dir($baseDir)) {
         mkdir($baseDir, 0777, true);
     }
     $indexTemplate = $builder->indexTemplate($params);
     $filename = $baseDir . '/index.html.twig';
     file_put_contents($filename, $indexTemplate);
     $output->writeln('<info>Generated index template in </info>' . $filename);
     $editTemplate = $builder->editTemplate($params);
     $filename = $baseDir . '/edit.html.twig';
     file_put_contents($filename, $editTemplate);
     $output->writeln('<info>Generated edit template in </info>' . $filename);
 }
開發者ID:mangati,項目名稱:base-bundle,代碼行數:51,代碼來源:CrudGenerateCommand.php

示例14: interact

 public function interact(InputInterface $input, OutputInterface $output)
 {
     $bundle = $input->getArgument('bundle');
     $name = $input->getArgument('name');
     if (null !== $bundle && null !== $name) {
         return;
     }
     $questionHelper = $this->getQuestionHelper();
     $questionHelper->writeSection($output, 'Welcome to the Symfony command generator');
     // bundle
     if (null !== $bundle) {
         $output->writeln(sprintf('Bundle name: %s', $bundle));
     } else {
         $output->writeln(array('', 'First, you need to give the name of the bundle where the command will', 'be generated (e.g. <comment>AppBundle</comment>)', ''));
         $bundleNames = array_keys($this->getContainer()->get('kernel')->getBundles());
         $question = new Question($questionHelper->getQuestion('Bundle name', $bundle), $bundle);
         $question->setAutocompleterValues($bundleNames);
         $question->setValidator(function ($answer) use($bundleNames) {
             if (!in_array($answer, $bundleNames)) {
                 throw new \RuntimeException(sprintf('Bundle "%s" does not exist.', $answer));
             }
             return $answer;
         });
         $question->setMaxAttempts(self::MAX_ATTEMPTS);
         $bundle = $questionHelper->ask($input, $output, $question);
         $input->setArgument('bundle', $bundle);
     }
     // command name
     if (null !== $name) {
         $output->writeln(sprintf('Command name: %s', $name));
     } else {
         $output->writeln(array('', 'Now, provide the name of the command as you type it in the console', '(e.g. <comment>app:my-command</comment>)', ''));
         $question = new Question($questionHelper->getQuestion('Command name', $name), $name);
         $question->setValidator(function ($answer) {
             if (empty($answer)) {
                 throw new \RuntimeException('The command name cannot be empty.');
             }
             return $answer;
         });
         $question->setMaxAttempts(self::MAX_ATTEMPTS);
         $name = $questionHelper->ask($input, $output, $question);
         $input->setArgument('name', $name);
     }
     // summary and confirmation
     $output->writeln(array('', $this->getHelper('formatter')->formatBlock('Summary before generation', 'bg=blue;fg-white', true), '', sprintf('You are going to generate a <info>%s</info> command inside <info>%s</info> bundle.', $name, $bundle)));
     $question = new Question($questionHelper->getQuestion('Do you confirm generation', 'yes', '?'), true);
     if (!$questionHelper->ask($input, $output, $question)) {
         $output->writeln('<error>Command aborted</error>');
         return 1;
     }
 }
開發者ID:naldz,項目名稱:cyberden,代碼行數:51,代碼來源:GenerateCommandCommand.php

示例15: create

 /**
  * @param QuestionInterface $question
  * @return ChoiceQuestion|Question
  */
 public function create(QuestionInterface $question)
 {
     if ($question instanceof ChoiceQuestionInterface) {
         $consoleQuestion = new ChoiceQuestion($question->getQuestion(), $question->getChoiceArray(), $question->getDefaultAnswer());
     } else {
         $consoleQuestion = new Question($question->getQuestion(), $question->getDefaultAnswer());
     }
     if ($question->getErrorMessage() !== null) {
         $consoleQuestion->setErrorMessage($question->getErrorMessage());
     }
     if ($question->getAutocompleterValues() !== null) {
         $consoleQuestion->setAutocompleterValues($question->getAutocompleterValues());
     }
     return $consoleQuestion;
 }
開發者ID:gsdevme,項目名稱:drupalcontainer,代碼行數:19,代碼來源:QuestionFactory.php


注:本文中的Symfony\Component\Console\Question\Question::setAutocompleterValues方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。