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


PHP InputInterface::setArgument方法代碼示例

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


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

示例1: interact

 /**
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     /** @var DialogHelper $dialog */
     $dialog = $this->getHelper('dialog');
     $username = $dialog->askAndValidate($output, 'Please give the email:', function ($username) {
         if (empty($username)) {
             throw new \Exception('email can not be empty');
         }
         return $username;
     });
     $this->addArgument('email');
     $input->setArgument('email', $username);
     $password = $dialog->askHiddenResponseAndValidate($output, 'Please enter the new password:', function ($password) {
         if (empty($password)) {
             throw new \Exception('Password can not be empty');
         }
         return $password;
     });
     $this->addArgument('password');
     $input->setArgument('password', $password);
     $name = $dialog->askAndValidate($output, 'Please give the name:', function ($name) {
         if (empty($name)) {
             throw new \Exception('Name can not be empty');
         }
         return $name;
     });
     $this->addArgument('name');
     $input->setArgument('name', $name);
 }
開發者ID:Kotys,項目名稱:eventor.io,代碼行數:33,代碼來源:CreateUser.php

示例2: interact

 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $output = new DrupalStyle($input, $output);
     $user = $input->getArgument('user');
     if (!$user) {
         $user = $output->ask($this->trans('commands.user.password.reset.questions.user'), '', function ($uid) {
             $uid = (int) $uid;
             if (is_int($uid) && $uid > 0) {
                 return $uid;
             } else {
                 throw new \InvalidArgumentException(sprintf($this->trans('commands.user.password.reset.questions.invalid-uid'), $uid));
             }
         });
         $input->setArgument('user', $user);
     }
     $password = $input->getArgument('password');
     if (!$password) {
         $password = $output->ask($this->trans('commands.user.password.hash.questions.password'), '', function ($pass) {
             if (!empty($pass)) {
                 return $pass;
             } else {
                 throw new \InvalidArgumentException(sprintf($this->trans('commands.user.password.hash.questions.invalid-pass'), $pass));
             }
         });
         $input->setArgument('password', $password);
     }
 }
開發者ID:legovaer,項目名稱:DrupalConsole,代碼行數:30,代碼來源:PasswordResetCommand.php

示例3: interact

 /**
  * {@inheritDoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     //game type
     $input->setArgument(self::ARGUMENT_GAME_TYPE, $this->getGameType($output));
     //amount of players
     $input->setArgument(self::ARGUMENT_GAME_PLAYERS, $this->addPlayers($output));
 }
開發者ID:justinhogg,項目名稱:cards,代碼行數:10,代碼來源:GamesCommand.php

示例4: interact

 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     /** @var StorageInterface $storage */
     $storage = $this->getContainer()->get('storage');
     $files = $input->getArgument('files');
     if ($input->getOption('latest')) {
         $remoteFiles = $storage->remoteListing();
         if (count($remoteFiles) > 0) {
             $files[] = end($remoteFiles);
             $input->setArgument('files', $files);
         }
     }
     if ($input->hasArgument('files') && !empty($files)) {
         return;
     }
     $remoteFiles = $storage->remoteListing();
     $localFiles = $storage->localListing();
     if (count(array_diff($remoteFiles, $localFiles)) === 0) {
         $output->writeln('All files fetched');
         return;
     }
     $helper = $this->getHelper('question');
     $question = new ChoiceQuestion('Which backup', array_values(array_diff($remoteFiles, $localFiles)));
     $question->setMultiselect(true);
     $question->setErrorMessage('Backup %s is invalid.');
     $question->setAutocompleterValues([]);
     $input->setArgument('files', $helper->ask($input, $output, $question));
 }
開發者ID:nanbando,項目名稱:core,代碼行數:31,代碼來源:FetchCommand.php

示例5: interact

 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $name = $input->getArgument('name');
     $configFactory = $this->getDrupalService('config.factory');
     $names = $configFactory->listAll();
     if ($name) {
         if (!in_array($name, $names)) {
             $io->warning(sprintf($this->trans('commands.config.override.messages.invalid-name'), $name));
             $name = null;
         }
     }
     if (!$name) {
         $name = $io->choiceNoList($this->trans('commands.config.override.questions.name'), $names);
         $input->setArgument('name', $name);
     }
     $key = $input->getArgument('key');
     if (!$key) {
         $configStorage = $this->getDrupalService('config.storage');
         if ($configStorage->exists($name)) {
             $configuration = $configStorage->read($name);
         }
         $key = $io->choiceNoList($this->trans('commands.config.override.questions.key'), array_keys($configuration));
         $input->setArgument('key', $key);
     }
     $value = $input->getArgument('value');
     if (!$value) {
         $value = $io->ask($this->trans('commands.config.override.questions.value'));
         $input->setArgument('value', $value);
     }
 }
開發者ID:mnico,項目名稱:DrupalConsole,代碼行數:34,代碼來源:OverrideCommand.php

示例6: initialize

 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     $input->setArgument('from', $this->fs->toAbsolutePath($input->getArgument('from')));
     $this->fs->validateExists($input->getArgument('from'));
     $input->setArgument('to', $this->fs->toAbsolutePath($input->getArgument('to')));
     $this->fs->validateExists($input->getArgument('to'));
 }
開發者ID:totten,項目名稱:git-scan,代碼行數:7,代碼來源:DiffCommand.php

示例7: interact

 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     if (!$input->getArgument('email')) {
         $email = $this->getHelper('dialog')->askAndValidate($output, 'Please enter an email:', function ($username) {
             if (empty($username)) {
                 throw new \Exception('Email can not be empty');
             }
             return $username;
         });
         $input->setArgument('email', $email);
     }
     if (!$input->getArgument('password')) {
         $password = $this->getHelper('dialog')->askHiddenResponseAndValidate($output, 'Please choose a password:', function ($password) {
             if (empty($password)) {
                 throw new \Exception('Password can not be empty');
             }
             return $password;
         });
         $input->setArgument('password', $password);
     }
     if (!$input->getArgument('roles')) {
         $roles = $this->getHelper('dialog')->ask($output, 'Please enter user\'s roles (separated by space):');
         if (!empty($roles)) {
             $input->setArgument('roles', explode(' ', $roles));
         }
     }
 }
開發者ID:pavelnovitsky,項目名稱:Sylius,代碼行數:30,代碼來源:CreateUserCommand.php

示例8: interact

 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $dialog = $this->getDialogHelper();
     $user = $input->getArgument('user');
     if (!$user) {
         $user = $dialog->askAndValidate($output, $dialog->getQuestion($this->trans('commands.user.password.reset.questions.user'), ''), function ($uid) {
             $uid = (int) $uid;
             if (is_int($uid) && $uid > 0) {
                 return $uid;
             } else {
                 throw new \InvalidArgumentException(sprintf($this->trans('commands.user.password.reset.questions.invalid-uid'), $uid));
             }
         }, false, '', null);
     }
     $input->setArgument('user', $user);
     $password = $input->getArgument('password');
     if (!$password) {
         $password = $dialog->askAndValidate($output, $dialog->getQuestion($this->trans('commands.user.password.hash.questions.password'), ''), function ($pass) {
             if (!empty($pass)) {
                 return $pass;
             } else {
                 throw new \InvalidArgumentException(sprintf($this->trans('commands.user.password.hash.questions.invalid-pass'), $pass));
             }
         }, false, '', null);
     }
     $input->setArgument('password', $password);
 }
開發者ID:rmelike,項目名稱:DrupalConsole,代碼行數:30,代碼來源:UserPasswordResetCommand.php

示例9: interact

 public function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $bundle = $input->getArgument('bundle');
     $name = $input->getArgument('name');
     $container = $this->getContainer();
     if (null !== $bundle && null !== $name) {
         return;
     }
     $io->title('Generate new RPC method');
     // Bundle name
     $bundle = $io->ask('Bundle name', null, function ($answer) use($container) {
         try {
             $container->get('kernel')->getBundle($answer);
         } catch (\Exception $e) {
             throw new \RuntimeException(sprintf('Bundle "%s" does not exist.', $answer));
         }
         return $answer;
     });
     $input->setArgument('bundle', $bundle);
     // Method name
     $name = $io->ask('Method name', null, function ($answer) use($container, $bundle) {
         if (empty($answer)) {
             throw new \RuntimeException('Method name can`t be empty.');
         }
         $answer = str_replace(' ', ':', $answer);
         if ($this->isMethodExist($container->get('kernel')->getBundle($bundle), $answer)) {
             throw new \RuntimeException(sprintf('Method "%s" already exist.', $answer));
         }
         return $answer;
     });
     $input->setArgument('name', $name);
 }
開發者ID:timiki,項目名稱:rpc-server-bundle,代碼行數:33,代碼來源:GenerateMethodCommand.php

示例10: interact

 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $output->writeln($this->app['app.signature']);
     $output->writeln(array('', ' Welcome to the ShakeTheNations interactive cli-tool', ''));
     $dialog = $this->getHelperSet()->get('dialog');
     $location = $input->getArgument('location') ?: $dialog->askAndValidate($output, "Please, type your <info>location</info>" . " (e.g. <comment>Nantes, France</comment>)" . "\n > ", function ($location) use($input) {
         $input->setArgument('location', $location);
     });
     $distance = $input->getArgument('distance') ?: $dialog->askAndValidate($output, "Please, type the max <info>distance</info> (kilometers)" . " (e.g. <comment>500</comment>)" . "\n > ", function ($distance) use($input) {
         $input->setArgument('distance', $distance);
     });
 }
開發者ID:ronanguilloux,項目名稱:ShakeTheNations,代碼行數:12,代碼來源:InteractiveCommand.php

示例11: addField

 /**
  * Adds form console fields customizing the field name and its validation method.
  *
  * @param string $name   The field name
  * @param string $method The method that be executed
  *
  * @return $this self
  */
 private function addField($name, $method = 'askAndValidate')
 {
     if (!$this->input->getArgument($name)) {
         $field = $this->getHelper('dialog')->{$method}($this->output, sprintf('Please choose a/an %s:', $name), function ($field) {
             if (empty($field)) {
                 throw new \Exception('This field can not be empty');
             }
             return $field;
         });
         $this->input->setArgument($name, $field);
     }
     return $this;
 }
開發者ID:cespedosa,項目名稱:kreta,代碼行數:21,代碼來源:CreateUserCommand.php

示例12: interact

 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $directory = $input->getArgument('directory');
     if (!$directory) {
         $directory = $io->ask($this->trans('commands.site.new.questions.directory'));
         $input->setArgument('directory', $directory);
     }
     $version = $input->getArgument('version');
     if (!$version) {
         $version = $this->releasesQuestion($io, 'drupal');
         $input->setArgument('version', $version);
     }
 }
開發者ID:blasoliva,項目名稱:DrupalConsole,代碼行數:17,代碼來源:NewCommand.php

示例13: interact

 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $directory = $input->getArgument('directory');
     if (!$directory) {
         $directory = $io->ask($this->trans('commands.site.import.local.questions.directory'), getcwd());
         $input->setArgument('directory', $directory);
     }
     $name = $input->getArgument('name');
     if (!$name) {
         $name = $io->ask($this->trans('commands.site.import.local.questions.name'));
         $input->setArgument('name', $name);
     }
 }
開發者ID:ibonelli,項目名稱:DrupalConsole,代碼行數:17,代碼來源:ImportLocalCommand.php

示例14: interact

 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $type = $input->getArgument('type');
     if (!$type) {
         $type = $io->choiceNoList($this->trans('commands.config.delete.arguments.type'), ['active', 'staging'], 'active');
         $input->setArgument('type', $type);
     }
     $name = $input->getArgument('name');
     if (!$name) {
         $name = $io->choiceNoList($this->trans('commands.config.delete.arguments.name'), $this->getAllConfigNames(), 'all');
         $input->setArgument('name', $name);
     }
 }
開發者ID:ibonelli,項目名稱:DrupalConsole,代碼行數:17,代碼來源:DeleteCommand.php

示例15: handle

 /**
  * Handle the command.
  *
  * @param AddonCollection $addons
  */
 public function handle()
 {
     if (!($addon = $this->input->getOption('addon'))) {
         return;
     }
     if (!($addon = $this->dispatch(new GetAddon($addon)))) {
         throw new \Exception("Addon could not be found.");
     }
     $this->input->setArgument('name', $addon->getNamespace() . '__' . $this->input->getArgument('name'));
     $this->input->setOption('path', $addon->getAppPath('migrations'));
     if (!is_dir($directory = $addon->getPath('migrations'))) {
         mkdir($directory);
     }
 }
開發者ID:huglester,項目名稱:streams-platform,代碼行數:19,代碼來源:ConfigureCreator.php


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