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


PHP Input\ArrayInput类代码示例

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


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

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

示例2: testBuildCommands

 public function testBuildCommands()
 {
     $definition = new CommandDefinition('self-update');
     $definition->setDescription('Update spress.phar to the latest version.');
     $definition->setHelp('The self-update command replace your spress.phar by the latest version.');
     $definition->addOption('all');
     $definition->addArgument('dir');
     $input = new ArrayInput([]);
     $input->setInteractive(false);
     $output = new StreamOutput(fopen('php://memory', 'w', false));
     $commandPluginMock = $this->getMockBuilder('\\Yosymfony\\Spress\\Plugin\\CommandPlugin')->getMock();
     $commandPluginMock->expects($this->once())->method('getCommandDefinition')->will($this->returnValue($definition));
     $commandPluginMock->expects($this->once())->method('executeCommand');
     $pm = new PluginManager(new EventDispatcher());
     $pm->getPluginCollection()->add('emptyCommandPlugin', $commandPluginMock);
     $builder = new ConsoleCommandBuilder($pm);
     $symfonyConsoleCommands = $builder->buildCommands();
     $this->assertTrue(is_array($symfonyConsoleCommands));
     $this->assertCount(1, $symfonyConsoleCommands);
     $this->assertContainsOnlyInstancesOf('Symfony\\Component\\Console\\Command\\Command', $symfonyConsoleCommands);
     $symfonyConsoleCommand = $symfonyConsoleCommands[0];
     $this->assertCount(1, $symfonyConsoleCommand->getDefinition()->getOptions());
     $this->assertCount(1, $symfonyConsoleCommand->getDefinition()->getArguments());
     $this->assertEquals('Update spress.phar to the latest version.', $symfonyConsoleCommand->getDescription());
     $this->assertEquals('The self-update command replace your spress.phar by the latest version.', $symfonyConsoleCommand->getHelp());
     $symfonyConsoleCommand->run($input, $output);
 }
开发者ID:spress,项目名称:spress,代码行数:27,代码来源:ConsoleCommandBuilderTest.php

示例3: callCommands

 /**
  * @param ConsoleTerminateEvent $event
  */
 public function callCommands(ConsoleTerminateEvent $event)
 {
     /**
      * @var \Drupal\Console\Command\Command $command
      */
     $command = $event->getCommand();
     $output = $event->getOutput();
     if (!$command instanceof Command) {
         return;
     }
     $application = $command->getApplication();
     $commands = $application->getChain()->getCommands();
     if (!$commands) {
         return;
     }
     foreach ($commands as $chainedCommand) {
         if ($chainedCommand['name'] == 'module:install') {
             $messageHelper = $application->getMessageHelper();
             $translatorHelper = $application->getTranslator();
             $messageHelper->addErrorMessage($translatorHelper->trans('commands.chain.messages.module_install'));
             continue;
         }
         $callCommand = $application->find($chainedCommand['name']);
         $input = new ArrayInput($chainedCommand['inputs']);
         if (!is_null($chainedCommand['interactive'])) {
             $input->setInteractive($chainedCommand['interactive']);
         }
         $callCommand->run($input, $output);
     }
 }
开发者ID:rmelike,项目名称:DrupalConsole,代码行数:33,代码来源:CallCommandListener.php

示例4: prepareInput

 /**
  * Prepare the input interface for the command.
  *
  * @return InputInterface
  */
 protected function prepareInput()
 {
     $arguments = ['--optimize' => (bool) $this->file->get(self::SETTING_OPTIMIZE), '--no-dev' => true];
     $input = new ArrayInput($arguments);
     $input->setInteractive(false);
     return $input;
 }
开发者ID:tenside,项目名称:core,代码行数:12,代码来源:DumpAutoloadTask.php

示例5: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dialog = $this->getHelperSet()->get('dialog');
     $command = $this->getApplication()->find('translations:fetch');
     $arguments = array('command' => 'translations:fetch', '--username' => $input->getOption('username'), '--password' => $input->getOption('password'), '--keep-english' => true);
     $inputObject = new ArrayInput($arguments);
     $inputObject->setInteractive($input->isInteractive());
     $command->run($inputObject, $output);
     $englishFromOTrance = FetchFromOTrance::getDownloadPath() . DIRECTORY_SEPARATOR . 'en.json';
     if (!file_exists($englishFromOTrance)) {
         $output->writeln("English file from oTrance missing. Aborting");
         return;
     }
     $englishFromOTrance = json_decode(file_get_contents($englishFromOTrance), true);
     Translate::reloadLanguage('en');
     $availableTranslations = $GLOBALS['Piwik_translations'];
     $categories = array_unique(array_merge(array_keys($englishFromOTrance), array_keys($availableTranslations)));
     sort($categories);
     $unnecessary = $outdated = $missing = array();
     foreach ($categories as $category) {
         if (!empty($englishFromOTrance[$category])) {
             foreach ($englishFromOTrance[$category] as $key => $value) {
                 if (!array_key_exists($category, $availableTranslations) || !array_key_exists($key, $availableTranslations[$category])) {
                     $unnecessary[] = sprintf('%s_%s', $category, $key);
                     continue;
                 } else {
                     if (html_entity_decode($availableTranslations[$category][$key]) != html_entity_decode($englishFromOTrance[$category][$key])) {
                         $outdated[] = sprintf('%s_%s', $category, $key);
                         continue;
                     }
                 }
             }
         }
         if (!empty($availableTranslations[$category])) {
             foreach ($availableTranslations[$category] as $key => $value) {
                 if (!array_key_exists($category, $englishFromOTrance) || !array_key_exists($key, $englishFromOTrance[$category])) {
                     $missing[] = sprintf('%s_%s', $category, $key);
                     continue;
                 }
             }
         }
     }
     $output->writeln("");
     if (!empty($missing)) {
         $output->writeln("<bg=yellow;options=bold>-- Following keys are missing on oTrance --</bg=yellow;options=bold>");
         $output->writeln(implode("\n", $missing));
         $output->writeln("");
     }
     if (!empty($unnecessary)) {
         $output->writeln("<bg=yellow;options=bold>-- Following keys might be unnecessary on oTrance --</bg=yellow;options=bold>");
         $output->writeln(implode("\n", $unnecessary));
         $output->writeln("");
     }
     if (!empty($outdated)) {
         $output->writeln("<bg=yellow;options=bold>-- Following keys are outdated on oTrance --</bg=yellow;options=bold>");
         $output->writeln(implode("\n", $outdated));
         $output->writeln("");
     }
     $output->writeln("Finished.");
 }
开发者ID:kreynen,项目名称:elmsln,代码行数:60,代码来源:CompareKeys.php

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

示例7: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $force = (bool) $input->getOption('force');
     $dialog = $this->getHelperSet()->get('dialog');
     // Doctrine create database
     if ($force || $dialog->askConfirmation($output, '<question>Create Database?</question>', false)) {
         $output->writeln('Creating database...');
         $command = $this->getApplication()->find('doctrine:database:create');
         $input = new ArrayInput(['command' => 'doctrine:database:create', '-n' => $force]);
         $returnCode = $command->run($input, $output);
     }
     // Doctrine schema update
     if ($force || $dialog->askConfirmation($output, '<question>Load Schema?</question>', false)) {
         $output->writeln('Loading Schema...');
         $command = $this->getApplication()->find('doctrine:schema:update');
         $input = new ArrayInput(['command' => 'doctrine:schema:update', '--force' => true, '-n' => $force]);
         $returnCode = $command->run($input, $output);
     }
     // Doctrine Fixtures
     if ($force || $dialog->askConfirmation($output, '<question>Load Fixtures?</question>', false)) {
         $output->writeln('Loading Fixtures...');
         $command = $this->getApplication()->find('doctrine:fixtures:load');
         $input = new ArrayInput(['doctrine:fixtures:load']);
         $input->setInteractive(!$force);
         $returnCode = $command->run($input, $output);
     }
     $output->writeln('Finished.');
 }
开发者ID:symedit,项目名称:symedit,代码行数:28,代码来源:InstallCommand.php

示例8: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($this->isEnabled()) {
         $bundleName = $input->getArgument("bundle");
         $bundle = $this->getContainer()->get('kernel')->getBundle($bundleName);
         /* @var $bundle BundleInterface */
         $entities = array();
         foreach ($this->getBundleMetadata($bundle) as $m) {
             /* @var $m ClassMetadata */
             $_tmp = explode('\\', $m->getName());
             $entityName = array_pop($_tmp);
             $entities[$bundleName . ':' . $entityName] = $entityName;
         }
         $command = $this->getApplication()->find('itscaro:generate:crud');
         foreach ($entities as $entityShortcut => $entityName) {
             try {
                 $_input = new ArrayInput(['command' => 'itscaro:generate:crud', '--entity' => $entityShortcut, '--route-prefix' => $input->getOption('route-prefix') . strtolower($entityName), '--with-write' => $input->getOption('with-write'), '--format' => $input->getOption('format'), '--overwrite' => $input->getOption('overwrite')]);
                 $_input->setInteractive($input->isInteractive());
                 $output->writeln("<info>Executing:</info> {$_input}");
                 $returnCode = $command->run($_input, $output);
                 $output->writeln("\t<info>Done</info>");
             } catch (\Exception $e) {
                 $output->writeln("\t<error>Error:</error> " . $e->getMessage());
             }
         }
     } else {
         $output->writeln('<error>Cannot find DoctrineBundle</error>');
     }
 }
开发者ID:itscaro,项目名称:crud-generator-bundle,代码行数:29,代码来源:CrudAllCommand.php

示例9: handleMigrations

 /**
  * Run doctrine migrations
  */
 protected function handleMigrations()
 {
     $application = $this->getApplication();
     $commandInput = new ArrayInput(array('command' => 'doctrine:migrations:migrate'));
     $commandInput->setInteractive(false);
     $application->doRun($commandInput, $this->output);
 }
开发者ID:BenoitLeveque,项目名称:PrestaDeploymentBundle,代码行数:10,代码来源:UpdateCommand.php

示例10: execute

 /**
  * Initialize the command and determine which path to take
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  * @internal param $ Symfony\Component\Console\Input\InputInterface
  * @internal param $ Symfony\Component\Console\Output\OutputInterface
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     parent::execute($input, $output);
     switch ($this->input->getArgument('key')) {
         case 'folder':
             $this->newFolder();
             break;
         case 'site':
             $this->newSite();
             break;
         case 'database':
             $this->newDatabase();
             break;
         case 'variable':
             $this->newVariable();
             break;
         case 'list':
             $this->listKeys();
             break;
         default:
             $helpCommand = $this->getApplication()->find('config:new');
             $input = new ArrayInput(['key' => 'list', '--file' => $input->getOption('file')]);
             $helpCommand->run($input, $output);
             break;
     }
 }
开发者ID:jimmygle,项目名称:homesteader,代码行数:35,代码来源:ConfigNewCommand.php

示例11: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $file = 'build/portable-zip-api.zip';
     $pharCommand = $this->getApplication()->find('build:phar');
     $arrayInput = new ArrayInput(array('command' => 'build:phar'));
     $arrayInput->setInteractive(false);
     if ($pharCommand->run($arrayInput, $output)) {
         $output->writeln('The operation is aborted due to build:phar command');
         return 1;
     }
     if (file_exists($file)) {
         $output->writeln('Removing previous package');
         unlink($file);
     }
     $zip = new \ZipArchive();
     if ($zip->open($file, \ZipArchive::CREATE) !== true) {
         $output->writeln('Failed to open zip archive');
         return 1;
     }
     $zip->addFile('build/zip.phar.php', 'zip.phar.php');
     $zip->addFile('app/zip.sqlite.db', 'zip.sqlite.db');
     $zip->addFile('README.md', 'README.md');
     $zip->close();
     return 0;
 }
开发者ID:kzykhys,项目名称:portable-zipcode-api,代码行数:28,代码来源:PackageCommand.php

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

示例13: executeCommand

 private function executeCommand($command, $arguments, OutputInterface $output)
 {
     $command = $this->getApplication()->find($command);
     $arguments['command'] = $command;
     $input = new ArrayInput($arguments);
     $input->setInteractive(false);
     return $command->run($input, $output);
 }
开发者ID:proyecto404,项目名称:UtilBundle,代码行数:8,代码来源:GenerateDatabaseCommand.php

示例14: launchCommand

 /**
  * @param null|string|array $config
  */
 private function launchCommand($config = null)
 {
     $app = new Application(self::$kernel->getContainer()->get('kernel'));
     $app->setAutoExit(false);
     $input = new ArrayInput(array('command' => 'modera:languages:config-sync-dummy', 'config' => $config ? json_encode($config) : null));
     $input->setInteractive(false);
     $result = $app->run($input, new NullOutput());
     $this->assertEquals(0, $result);
 }
开发者ID:modera,项目名称:foundation,代码行数:12,代码来源:SyncLanguagesCommandTest.php

示例15: executeCommand

function executeCommand($application, $command, array $options = array())
{
    $options["--env"] = "test";
    $options["--quiet"] = true;
    $options = array_merge($options, array('command' => $command));
    $arrayInput = new ArrayInput($options);
    $arrayInput->setInteractive(false);
    $application->run($arrayInput);
}
开发者ID:vegardbb,项目名称:webpage,代码行数:9,代码来源:testBootstrap.php


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