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


PHP InputDefinition::getOptions方法代码示例

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


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

示例1: describeInputDefinition

 /**
  * {@inheritdoc}
  */
 protected function describeInputDefinition(InputDefinition $definition, array $options = array())
 {
     $nameWidth = 0;
     foreach ($definition->getOptions() as $option) {
         $nameLength = strlen($option->getName()) + 2;
         if ($option->getShortcut()) {
             $nameLength += strlen($option->getShortcut()) + 3;
         }
         $nameWidth = max($nameWidth, $nameLength);
     }
     foreach ($definition->getArguments() as $argument) {
         $nameWidth = max($nameWidth, strlen($argument->getName()));
     }
     ++$nameWidth;
     if ($definition->getArguments()) {
         $this->writeText('<comment>Arguments:</comment>', $options);
         $this->writeText("\n");
         foreach ($definition->getArguments() as $argument) {
             $this->describeInputArgument($argument, array_merge($options, array('name_width' => $nameWidth)));
             $this->writeText("\n");
         }
     }
     if ($definition->getArguments() && $definition->getOptions()) {
         $this->writeText("\n");
     }
     if ($definition->getOptions()) {
         $this->writeText('<comment>Options:</comment>', $options);
         $this->writeText("\n");
         foreach ($definition->getOptions() as $option) {
             $this->describeInputOption($option, array_merge($options, array('name_width' => $nameWidth)));
             $this->writeText("\n");
         }
     }
 }
开发者ID:EnmanuelCode,项目名称:backend-laravel,代码行数:37,代码来源:TextDescriptor.php

示例2: describeInputDefinition

 /**
  * {@inheritdoc}
  */
 protected function describeInputDefinition(InputDefinition $definition, array $options = array())
 {
     $totalWidth = $this->calculateTotalWidthForOptions($definition->getOptions());
     foreach ($definition->getArguments() as $argument) {
         $totalWidth = max($totalWidth, strlen($argument->getName()));
     }
     if ($definition->getArguments()) {
         $this->writeText('<comment>Arguments:</comment>', $options);
         $this->writeText("\n");
         foreach ($definition->getArguments() as $argument) {
             $this->describeInputArgument($argument, array_merge($options, array('total_width' => $totalWidth)));
             $this->writeText("\n");
         }
     }
     if ($definition->getArguments() && $definition->getOptions()) {
         $this->writeText("\n");
     }
     if ($definition->getOptions()) {
         $laterOptions = array();
         $this->writeText('<comment>Options:</comment>', $options);
         foreach ($definition->getOptions() as $option) {
             if (strlen($option->getShortcut()) > 1) {
                 $laterOptions[] = $option;
                 continue;
             }
             $this->writeText("\n");
             $this->describeInputOption($option, array_merge($options, array('total_width' => $totalWidth)));
         }
         foreach ($laterOptions as $option) {
             $this->writeText("\n");
             $this->describeInputOption($option, array_merge($options, array('total_width' => $totalWidth)));
         }
     }
 }
开发者ID:JesseDarellMoore,项目名称:CS499,代码行数:37,代码来源:TextDescriptor.php

示例3: startWorkers

 /**
  * Start workers, put master port, server name to run on, and options stuff.
  */
 public function startWorkers()
 {
     // Get verbosity.
     $verbosity = new VerbosityString($this->output);
     // Get current deploy.php file.
     $deployPhpFile = $this->input->getOption('file');
     // User input.
     $input = '';
     // Get user arguments.
     foreach ($this->userDefinition->getArguments() as $argument) {
         $value = $this->input->getArgument($argument->getName());
         if ($value) {
             $input .= " {$value}";
         }
     }
     // Get user options.
     foreach ($this->userDefinition->getOptions() as $option) {
         $value = $this->input->getOption($option->getName());
         if ($value) {
             $input .= " --{$option->getName()} {$value}";
         }
     }
     foreach ($this->servers as $serverName => $server) {
         $process = new Process("php " . DEPLOYER_BIN . (null === $deployPhpFile ? "" : " --file={$deployPhpFile}") . " worker " . " --master 127.0.0.1:{$this->port}" . " --server {$serverName}" . " {$input} " . " {$verbosity}" . " &");
         $process->disableOutput();
         $process->start();
     }
 }
开发者ID:elfet,项目名称:deployer,代码行数:31,代码来源:ParallelExecutor.php

示例4: init

 /**
  * @param InputDefinition $inputDefinition
  * @param InputInterface  $input
  */
 public function init(InputDefinition $inputDefinition, InputInterface $input)
 {
     $options = new ProcessOptionCollection();
     foreach ($inputDefinition->getOptions() as $optionName => $inputOption) {
         $optionValue = $input->getOption($optionName);
         if ($inputOption->getDefault() != $optionValue) {
             switch (true) {
                 case in_array($optionName, $this->skipOptions):
                     $option = null;
                     break;
                 case $inputOption->isArray() && $optionName == 'out':
                     $option = new ProcessOptionOut($optionName, $optionValue);
                     break;
                 case $inputOption->isArray():
                     $option = new ProcessOptionArray($optionName, $optionValue);
                     break;
                 case $inputOption->isValueRequired():
                 case $inputOption->isValueOptional():
                     $option = new ProcessOptionScalar($optionName, $optionValue);
                     break;
                 default:
                     $option = new ProcessOption($optionName);
             }
             if ($option) {
                 $options->set($option);
             }
         }
     }
     $this->optionCollection = $options;
 }
开发者ID:tonicforhealth,项目名称:behat-parallel-scenario,代码行数:34,代码来源:ScenarioProcessFactory.php

示例5: describeInputDefinition

 /**
  * {@inheritdoc}
  */
 protected function describeInputDefinition(InputDefinition $definition, array $options = array())
 {
     $blocks = array();
     if (count($definition->getArguments()) > 0) {
         $blocks[] = '### Arguments:';
         foreach ($definition->getArguments() as $argument) {
             $blocks[] = $this->describeInputArgument($argument);
         }
     }
     if (count($definition->getOptions()) > 0) {
         $blocks[] = '### Options:';
         foreach ($definition->getOptions() as $option) {
             $blocks[] = $this->describeInputOption($option);
         }
     }
     return implode("\n\n", $blocks);
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:20,代码来源:MarkdownDescriptor.php

示例6: describeInputDefinition

 /**
  * {@inheritdoc}
  */
 protected function describeInputDefinition(InputDefinition $definition, array $options = array())
 {
     if ($showArguments = count($definition->getArguments()) > 0) {
         $this->write('### Arguments:');
         foreach ($definition->getArguments() as $argument) {
             $this->write("\n\n");
             $this->write($this->describeInputArgument($argument));
         }
     }
     if (count($definition->getOptions()) > 0) {
         if ($showArguments) {
             $this->write("\n\n");
         }
         $this->write('### Options:');
         foreach ($definition->getOptions() as $option) {
             $this->write("\n\n");
             $this->write($this->describeInputOption($option));
         }
     }
 }
开发者ID:neteasy-work,项目名称:hkgbf_crm,代码行数:23,代码来源:MarkdownDescriptor.php

示例7: let

 function let(CommandCollection $collection, Command $command1, Command $command2, InputDefinition $inputDefinition, InputDefinition $inputDefinition2, InputOption $inputOption, InputOption $inputOption2)
 {
     $inputDefinition->getOptions()->willReturn(['option1' => $inputOption, 'option2' => $inputOption2]);
     $command1->getName()->willReturn('test:command');
     $command1->getDefinition()->willReturn($inputDefinition);
     $inputDefinition2->getOptions()->willReturn([]);
     $command2->getName()->willReturn('other-command');
     $command2->getDefinition()->willReturn($inputDefinition2);
     $collection->getItems()->willReturn(['test:command' => $command1, 'other-command' => $command2]);
     $this->beConstructedWith($collection);
 }
开发者ID:yvoronoy,项目名称:magento2-bash-completion,代码行数:11,代码来源:GeneratorSpec.php

示例8: describeInputDefinition

 /**
  * {@inheritdoc}
  */
 protected function describeInputDefinition(InputDefinition $definition, array $options = array())
 {
     $inputArguments = array();
     foreach ($definition->getArguments() as $name => $argument) {
         $inputArguments[$name] = $this->describeInputArgument($argument, array('as_array' => true));
     }
     $inputOptions = array();
     foreach ($definition->getOptions() as $name => $option) {
         $inputOptions[$name] = $this->describeInputOption($option, array('as_array' => true));
     }
     return $this->output(array('arguments' => $inputArguments, 'options' => $inputOptions), $options);
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:15,代码来源:JsonDescriptor.php

示例9: getInputDefinitionData

 private function getInputDefinitionData(InputDefinition $definition)
 {
     $inputArguments = array();
     foreach ($definition->getArguments() as $name => $argument) {
         $inputArguments[$name] = $this->getInputArgumentData($argument);
     }
     $inputOptions = array();
     foreach ($definition->getOptions() as $name => $option) {
         $inputOptions[$name] = $this->getInputOptionData($option);
     }
     return array('arguments' => $inputArguments, 'options' => $inputOptions);
 }
开发者ID:VicDeo,项目名称:poc,代码行数:12,代码来源:JsonDescriptor.php

示例10: getInputDefinitionDocument

 /**
  * @param InputDefinition $definition
  *
  * @return \DOMDocument
  */
 public function getInputDefinitionDocument(InputDefinition $definition)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $dom->appendChild($definitionXML = $dom->createElement('definition'));
     $definitionXML->appendChild($argumentsXML = $dom->createElement('arguments'));
     foreach ($definition->getArguments() as $argument) {
         $this->appendDocument($argumentsXML, $this->getInputArgumentDocument($argument));
     }
     $definitionXML->appendChild($optionsXML = $dom->createElement('options'));
     foreach ($definition->getOptions() as $option) {
         $this->appendDocument($optionsXML, $this->getInputOptionDocument($option));
     }
     return $dom;
 }
开发者ID:Ener-Getick,项目名称:symfony,代码行数:19,代码来源:XmlDescriptor.php

示例11: resolveInputDefinition

 /**
  * @return array Values for given InputDefinition, optionally filtered
  */
 public function resolveInputDefinition(InputDefinition $inputDefinition, array $filter = [])
 {
     $values = [];
     $arguments = array_filter($inputDefinition->getArguments(), function (InputArgument $argument) use($filter) {
         return !count($filter) || in_array($argument->getName(), $filter);
     });
     $options = array_filter($inputDefinition->getOptions(), function (InputOption $option) use($filter) {
         return !count($filter) || in_array($option->getName(), $filter);
     });
     foreach ($arguments as $argument) {
         $values[$argument->getName()] = $this->input->getArgument($argument->getName());
     }
     foreach ($options as $option) {
         $values[$option->getName()] = $this->getOptionValue($option);
     }
     return $values;
 }
开发者ID:Karttrend,项目名称:console-input-resolver,代码行数:20,代码来源:Resolver.php

示例12: startWorkers

 /**
  * Start workers, put master port, server name to run on, and options stuff.
  */
 public function startWorkers()
 {
     $input = ['--master' => '127.0.0.1:' . $this->port, '--server' => ''];
     // Get verbosity.
     $verbosity = new VerbosityString($this->output);
     // Get current deploy.php file.
     $deployPhpFile = $this->input->getOption('file');
     // Get user arguments.
     foreach ($this->userDefinition->getArguments() as $argument) {
         $input[$argument->getName()] = $this->input->getArgument($argument->getName());
     }
     // Get user options.
     foreach ($this->userDefinition->getOptions() as $option) {
         $input["--" . $option->getName()] = $this->input->getOption($option->getName());
     }
     foreach ($this->servers as $serverName => $server) {
         $input['--server'] = $serverName;
         $process = new Process("php " . DEPLOYER_BIN . (null === $deployPhpFile ? "" : " --file={$deployPhpFile}") . " worker " . new ArrayInput($input) . " {$verbosity}" . " &");
         $process->disableOutput();
         $process->run();
     }
 }
开发者ID:acorncom,项目名称:deployer,代码行数:25,代码来源:ParallelExecutor.php

示例13: testAddOption

 public function testAddOption()
 {
     $this->initializeOptions();
     $definition = new InputDefinition();
     $definition->addOption($this->foo);
     $this->assertEquals(array('foo' => $this->foo), $definition->getOptions(), '->addOption() adds a InputOption object');
     $definition->addOption($this->bar);
     $this->assertEquals(array('foo' => $this->foo, 'bar' => $this->bar), $definition->getOptions(), '->addOption() adds a InputOption object');
 }
开发者ID:exDron,项目名称:AndrewBlog,代码行数:9,代码来源:InputDefinitionTest.php

示例14: testAddOption

 public function testAddOption()
 {
     $this->initializeOptions();
     $definition = new InputDefinition();
     $definition->addOption($this->foo);
     $this->assertEquals(array('foo' => $this->foo), $definition->getOptions(), '->addOption() adds a InputOption object');
     $definition->addOption($this->bar);
     $this->assertEquals(array('foo' => $this->foo, 'bar' => $this->bar), $definition->getOptions(), '->addOption() adds a InputOption object');
     try {
         $definition->addOption($this->foo2);
         $this->fail('->addOption() throws a Exception if the another option is already registered with the same name');
     } catch (\Exception $e) {
         $this->assertInstanceOf('\\Exception', $e, '->addOption() throws a Exception if the another option is already registered with the same name');
         $this->assertEquals('An option named "foo" already exist.', $e->getMessage());
     }
     try {
         $definition->addOption($this->foo1);
         $this->fail('->addOption() throws a Exception if the another option is already registered with the same shortcut');
     } catch (\Exception $e) {
         $this->assertInstanceOf('\\Exception', $e, '->addOption() throws a Exception if the another option is already registered with the same shortcut');
         $this->assertEquals('An option with shortcut "f" already exist.', $e->getMessage());
     }
 }
开发者ID:rooster,项目名称:symfony,代码行数:23,代码来源:InputDefinitionTest.php


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