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


PHP ArrayInput::bind方法代码示例

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


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

示例1: updateCommandDefinition

 private function updateCommandDefinition(Command $command, OutputInterface $output)
 {
     $eventDispatcher = $this->getApplication()->getDispatcher();
     $input = new ArrayInput(['command' => $command->getName()]);
     $event = new ConsoleCommandEvent($command, $input, $output);
     $eventDispatcher->dispatch(GushEvents::DECORATE_DEFINITION, $event);
     $command->getSynopsis(true);
     $command->getSynopsis(false);
     $command->mergeApplicationDefinition();
     try {
         $input->bind($command->getDefinition());
     } catch (\Exception $e) {
         $output->writeln('<error>Something went wrong: </error>' . $e->getMessage());
         return;
     }
     $eventDispatcher->dispatch(GushEvents::INITIALIZE, $event);
     // The options were set on the input but now we need to set them on the Command definition
     if ($options = $input->getOptions()) {
         foreach ($options as $name => $value) {
             $option = $command->getDefinition()->getOption($name);
             if ($option->acceptValue()) {
                 $option->setDefault($value);
             }
         }
     }
 }
开发者ID:mistymagich,项目名称:gush,代码行数:26,代码来源:HelpCommand.php

示例2: testGetCustomFactsInvalid

 /**
  * @expectedException InvalidArgumentException
  * @expectedExceptionMessage Invalid format for --custom-fact 'foobar'
  */
 public function testGetCustomFactsInvalid()
 {
     $mock = $this->getMockForAbstractClass('SugarCli\\Console\\Command\\Inventory\\AbstractInventoryCommand', array('test'));
     $input = new ArrayInput(array('--custom-fact' => array('foobar')));
     $input->bind($mock->getDefinition());
     $mock->getCustomFacts($input, '');
 }
开发者ID:inetprocess,项目名称:sugarcli,代码行数:11,代码来源:AbstractInventoryCommandTest.php

示例3: testGetConfig

 public function testGetConfig()
 {
     file_put_contents('box.json', '{}');
     $command = $this->app->get('test');
     $input = new ArrayInput(array());
     $input->bind($command->getDefinition());
     $this->assertInstanceOf('KevinGH\\Box\\Configuration', $this->callMethod($command, 'getConfig', array($input)));
 }
开发者ID:hongtien510,项目名称:phalcon_dev_tool,代码行数:8,代码来源:ConfigurableTest.php

示例4: getInput

 protected function getInput(Command $command, array $arguments = [], array $options = [])
 {
     $input = new ArrayInput([]);
     $input->bind($command->getDefinition());
     foreach ($arguments as $key => $value) {
         $input->setArgument($key, $value);
     }
     foreach ($options as $key => $value) {
         $input->setOption($key, $value);
     }
     return $input;
 }
开发者ID:farukuzun,项目名称:core-1,代码行数:12,代码来源:commandtest.php

示例5: addCommandArray

 protected function addCommandArray(array $args, OutputInterface $output)
 {
     $command = $this->getApplication()->find($args['command']);
     if ($command instanceof CompositeCommand) {
         unset($args['command']);
         $input = new ArrayInput($args);
         $input->bind($command->getDefinition());
         $command->initialize($input, $output);
     } else {
         $input = new ArrayInput($args);
         self::$commands[] = array('command' => $command, 'input' => $input);
     }
 }
开发者ID:nike,项目名称:beez,代码行数:13,代码来源:CompositeCommand.php

示例6: testValidate

 public function testValidate()
 {
     $input = new ArrayInput(array());
     $input->bind(new InputDefinition(array(new InputArgument('name', InputArgument::REQUIRED))));
     try {
         $input->validate();
         $this->fail('->validate() throws a \\RuntimeException if not enough arguments are given');
     } catch (\Exception $e) {
         $this->assertInstanceOf('\\RuntimeException', $e, '->validate() throws a \\RuntimeException if not enough arguments are given');
         $this->assertEquals('Not enough arguments.', $e->getMessage());
     }
     $input = new ArrayInput(array('name' => 'foo'));
     $input->bind(new InputDefinition(array(new InputArgument('name', InputArgument::REQUIRED))));
     try {
         $input->validate();
     } catch (\RuntimeException $e) {
         $this->fail('->validate() does not throw a \\RuntimeException if enough arguments are given');
     }
 }
开发者ID:yamildiego,项目名称:JY,代码行数:19,代码来源:InputTest.php

示例7: testValidate

 public function testValidate()
 {
     $input = new ArrayInput(array('name' => 'foo'));
     $input->bind(new InputDefinition(array(new InputArgument('name', InputArgument::REQUIRED))));
     $this->assertNull($input->validate());
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:6,代码来源:InputTest.php

示例8: buildInput

 /**
  * buildInput.
  *
  * @param $array
  *
  * @return InputInterface
  */
 protected function buildInput($array)
 {
     $input = new ArrayInput($array);
     $input->bind((new LicenserCommand())->getDefinition());
     return $input;
 }
开发者ID:rafrsr,项目名称:licenser,代码行数:13,代码来源:ConfigFactoryTest.php

示例9: testGetConfigurationFileDoesNotExist

 /**
  * @covers                   ::getConfiguration
  * @expectedException        InvalidArgumentException
  * @expectedExceptionMessage The configuration file "foo.bar" could not be found.
  */
 public function testGetConfigurationFileDoesNotExist()
 {
     $mock = $this->getMockBuilder('MaartenStaa\\PHPTA\\CLI\\Command')->setMethods(array('getFilesystem'))->getMock();
     $fs = $this->getMockBuilder('Illuminate\\Filesystem\\Filesystem')->setMethods(array('isFile'))->getMock();
     $mock->expects($this->once())->method('getFilesystem')->will($this->returnValue($fs));
     $fs->expects($this->once())->method('isFile')->with('foo.bar')->will($this->returnValue(false));
     $input = new ArrayInput(array());
     $input->bind($mock->getDefinition());
     $input->setOption('config', 'foo.bar');
     $output = new StreamOutput(fopen('php://memory', 'w', false));
     $mock->getConfiguration($input, $output);
 }
开发者ID:maartenstaa,项目名称:phpta,代码行数:17,代码来源:CommandTest.php


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