当前位置: 首页>>代码示例>>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;未经允许,请勿转载。