本文整理汇总了PHP中Symfony\Component\Console\Command\Command::getApplication方法的典型用法代码示例。如果您正苦于以下问题:PHP Command::getApplication方法的具体用法?PHP Command::getApplication怎么用?PHP Command::getApplication使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Command\Command
的用法示例。
在下文中一共展示了Command::getApplication方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
$go = $this->getGo();
if (!$go) {
return $this->vars;
}
list($loopVarName, $loopCount) = $this->getLoopCount();
if ($loopCount) {
foreach ($loopCount as $loopVarValue) {
$commandString = is_array($this->value) ? $this->value['value'] : $this->value;
$commandArgs = explode(' ', $commandString);
$replacedArrayArgs = array_map(function ($commandArg) use($loopVarName, $loopVarValue) {
return $this->replaceVarsInString($commandArg, [$loopVarName => $loopVarValue]);
}, $commandArgs);
$subCommand = $this->command->getApplication()->find(reset($commandArgs));
$subCommand->run(new StringInput(implode(' ', $replacedArrayArgs)), $this->output);
}
} else {
$commandString = is_array($this->value) ? $this->value['value'] : $this->value;
$commandArgs = explode(' ', $commandString);
$replacedArrayArgs = array_map([$this, 'replaceVarsInString'], $commandArgs);
$subCommand = $this->command->getApplication()->find(reset($commandArgs));
$subCommand->run(new StringInput(implode(' ', $replacedArrayArgs)), $this->output);
}
return $this->vars;
}
示例2: addOptionsToCommand
/**
* @param Command $command
* @param InputInterface $input
*/
protected function addOptionsToCommand(Command $command, InputInterface $input)
{
$inputDefinition = $command->getApplication()->getDefinition();
$inputDefinition->addOption(new InputOption(self::DISABLE_OPTIONAL_LISTENERS, null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, sprintf('Disable optional listeners, "%s" to disable all listeners, ' . 'command "%s" shows all listeners', self::ALL_OPTIONAL_LISTENERS_VALUE, OptionalListenersCommand::NAME)));
$command->mergeApplicationDefinition();
$input->bind($command->getDefinition());
}
示例3: initApplication
/**
* @param array $modes
* @return \Symfony\Component\Console\Application
* @throws \Exception
*/
public function initApplication($modes)
{
if (null === $modes) {
throw new \Exception('A notification mode must be defined');
}
$app = parent::getApplication();
foreach (explode(',', $modes) as $mode) {
$app->registerEventListener(ucfirst($mode . 'Listener'));
}
$this->setApplication($app);
}
示例4: executeConsole
/**
* @param Command $command
* @param string[] $arguments
*
* @return string
*/
protected function executeConsole(Command $command, array $arguments = array())
{
if (!$command->getApplication()) {
$command->setApplication(new Application($this->client->getKernel()));
}
if ($command instanceof ContainerAwareCommand) {
$command->setContainer($this->client->getContainer());
}
$arguments = array_replace(array('--env' => 'test', 'command' => $command->getName()), $arguments);
$commandTester = new CommandTester($command);
$commandTester->execute($arguments);
return $commandTester->getDisplay();
}
示例5: initialize
/**
* Initializes default command definitions
*
* @param InputInterface $input
* @param OutputInterface $output
*/
protected final function initialize(InputInterface $input, OutputInterface $output)
{
// Set container and application.
$this->application = parent::getApplication();
$this->container = $this->application->getContainer();
// Dispatch pre execute event.
$dispatcher = $this->container->getServiceBag()->getDispatcher();
$dispatcher->dispatch(Events::PRE_INITIALIZE, new PreInitializeEvent($this->container));
// Initialize child class.
$this->initializeCommand($input, $output);
// Dispatch post execute event.
$dispatcher->dispatch(Events::POST_INITIALIZE, new PostInitializeEvent($this->container));
}
示例6: getApplication
/**
* @return \Drupal\Console\Application;
*/
public function getApplication()
{
return parent::getApplication();
}
示例7: getApplication
/**
* {@inheritdoc}
*/
public function getApplication()
{
return $this->decoratedCommand->getApplication();
}
示例8: getApplication
public function getApplication()
{
return $this->innerCommand->getApplication();
}
示例9: runById
/**
* Run a task by it's id, use the migration:report to see all the task and their id
*
* @\Nucleus\Bundle\ConsoleBundle\Command\CommandLine(name="nucleus_migration:runById")
*
* @param string $taskId The task id you want to run
*/
public function runById($taskId, OutputInterface $output, Command $parentCommand)
{
if ($migrationTask = $this->loadTaskById($taskId)) {
$this->runTask($migrationTask, $parentCommand->getApplication(), $output);
$output->writeln('Task id [' . $taskId . '] has been run');
} else {
$output->writeln('Task id [' . $taskId . '] not found');
}
}