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


PHP Input\InputDefinition類代碼示例

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


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

示例1: setOptionDescription

 private function setOptionDescription(InputDefinition $definition, $name, $description)
 {
     $argument = $definition->getOption($name);
     if ($argument instanceof InputOption) {
         $argument->setDescription($description);
     }
 }
開發者ID:mnapoli,項目名稱:silly,代碼行數:7,代碼來源:Command.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:sapwoo,項目名稱:portfolio,代碼行數:39,代碼來源:TextDescriptor.php

示例3: buildInputDefinition

 private function buildInputDefinition()
 {
     $inputDefinition = new InputDefinition();
     $inputDefinition->addArgument(new InputArgument('uno', InputArgument::REQUIRED));
     $inputDefinition->addOption(new InputOption('due', null, InputOption::VALUE_NONE));
     return $inputDefinition;
 }
開發者ID:Catapush,項目名稱:Idephix,代碼行數:7,代碼來源:CommandWrapperTest.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: getInputDefinition

 /**
  * Get an InputDefinition formed by the arguments provided
  *
  * Effectively provides a passthrough for any input arguments provided
  *
  * @param  array  $args Arguments
  * @return InputDefinition
  */
 protected function getInputDefinition(array $args)
 {
     $definition = new InputDefinition();
     foreach ($args as $field => $value) {
         $definition->addArgument(new InputArgument($field));
     }
     return $definition;
 }
開發者ID:bodetree,項目名稱:synapse-base,代碼行數:16,代碼來源:AbstractConsoleWork.php

示例6: providerMake

 /**
  * @return array
  */
 public function providerMake()
 {
     $inputDefinition = new InputDefinition();
     $inputDefinition->addOption(new InputOption('option_optional_default', null, InputOption::VALUE_OPTIONAL, '', 'default'));
     $inputDefinition->addOption(new InputOption('option_array_default_array', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY));
     $inputDefinition->addOption(new InputOption('option_none', null, InputOption::VALUE_NONE));
     $inputDefinition->addOption(new InputOption('out', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY));
     return ['option_optional_default_default' => [$inputDefinition, new ArrayInput(['--option_optional_default' => 'default'], $inputDefinition)], 'option_optional_default_value' => [$inputDefinition, new ArrayInput(['--option_optional_default' => 'value'], $inputDefinition), '--option_optional_default \'value\''], 'option_array_default_array_default' => [$inputDefinition, new ArrayInput(['--option_array_default_array' => []], $inputDefinition)], 'option_array_default_array_value' => [$inputDefinition, new ArrayInput(['--option_array_default_array' => ['value1', 'value2']], $inputDefinition), '--option_array_default_array \'value1\' --option_array_default_array \'value2\''], 'option_none_default' => [$inputDefinition, new ArrayInput([], $inputDefinition)], 'option_none_default_value' => [$inputDefinition, new ArrayInput(['--option_none' => 'any'], $inputDefinition), '--option_none'], 'out_folder_skip' => [$inputDefinition, new ArrayInput(['--out' => ['folder', 'std']], $inputDefinition), '', ['out']], 'out_folder' => [$inputDefinition, new ArrayInput(['--out' => ['folder', 'std']], $inputDefinition), '--out \'folder/59adaf3f0820898ecf0da97ceab30eab\' --out \'std\'']];
 }
開發者ID:tonicforhealth,項目名稱:behat-parallel-scenario,代碼行數:12,代碼來源:ScenarioProcessFactoryTest.php

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

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

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

 public function testConfigureSystemCommand()
 {
     $name = 'test_base_command';
     $description = 'test for base command creation';
     $keywords = 'base commands creation test';
     $arguments = array('username' => array('description' => 'linux username'));
     $options = 'options';
     $expectedArguments = new InputDefinition();
     $expectedArguments->addArgument(new InputArgument('username', InputArgument::REQUIRED, $arguments['username']['description']));
     $systemCommand = new SystemCommand($name, $description, $keywords, $arguments, $options);
     $this->assertEquals($expectedArguments, $systemCommand->getDefinition());
 }
開發者ID:PublicVar,項目名稱:cop1,代碼行數:12,代碼來源:SystemCommandTest.php

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

示例12: configure

    protected function configure()
    {
        parent::configure();
        $definition = new InputDefinition();
        $definition->setDefinition(array(new InputArgument('username', InputArgument::REQUIRED, 'The username'), new InputArgument('role', InputArgument::OPTIONAL, 'The role'), new InputOption('user-system', null, InputOption::VALUE_REQUIRED, 'The user-system to use'), new InputOption('super', null, InputOption::VALUE_NONE, 'Instead specifying role, use this to quickly add the super administrator role')));
        $this->setDefinition($definition);
        $this->setHelp(<<<EOT
The <info>fos:user:demote</info> command demotes a user by removing a role

  <info>php app/console fos:user:demote --user-system=acme_user matthieu ROLE_CUSTOM</info>
  <info>php app/console fos:user:demote --user-system=acme_user --super matthieu</info>
EOT
);
    }
開發者ID:buddhikajay,項目名稱:RollerworksMultiUserBundle,代碼行數:14,代碼來源:DemoteUserCommand.php

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

示例14: describeInputDefinition

 /**
  * {@inheritdoc}
  */
 protected function describeInputDefinition(InputDefinition $definition, array $options = array())
 {
     $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->describeInputArgument($argument, array('as_dom' => true)));
     }
     $definitionXML->appendChild($optionsXML = $dom->createElement('options'));
     foreach ($definition->getOptions() as $option) {
         $this->appendDocument($optionsXML, $this->describeInputOption($option, array('as_dom' => true)));
     }
     return $this->output($dom, $options);
 }
開發者ID:ccq18,項目名稱:EduSoho,代碼行數:17,代碼來源:XmlDescriptor.php

示例15: setUp

 public function setUp()
 {
     parent::setUp();
     $this->template = $this->prophesize(TemplateInterface::class);
     $inputDef = new InputDefinition();
     $inputDef->addOption(new InputOption('test-option', null, InputOption::VALUE_OPTIONAL));
     $this->input = new ArrayInput(['--test-option' => null], $inputDef);
     $this->output = new BufferedOutput();
     $this->application = $this->getApplication();
     $styleHelper = $this->application->getHelperSet()->get('gush_style');
     $styleHelper->setInput($this->input);
     $styleHelper->setOutput($this->output);
     $this->helper = new TemplateHelper($styleHelper, $this->application);
     $this->helper->setInput($this->input);
 }
開發者ID:gushphp,項目名稱:gush,代碼行數:15,代碼來源:TemplateHelperTest.php


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