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