本文整理汇总了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);
}
示例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);
}
}
示例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));
}
示例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));
}
示例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);
}
}
示例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'));
}
示例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));
}
}
}
示例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);
}
示例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);
}
示例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);
});
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}