getApplication() публичный метод

Gets the application instance for this command.
public getApplication ( ) : Application
Результат Symfony\Component\Console\Application An Application instance
 /**
  * @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());
 }
Пример #2
0
 /**
  * @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);
 }
 /**
  * @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();
 }
Пример #4
0
 /**
  * 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));
 }
Пример #5
0
 /**
  * @return \Drupal\Console\Application;
  */
 public function getApplication()
 {
     return parent::getApplication();
 }
 /**
  * {@inheritdoc}
  */
 public function getApplication()
 {
     return $this->decoratedCommand->getApplication();
 }
Пример #7
0
 public function getApplication()
 {
     return $this->innerCommand->getApplication();
 }
 /**
  * 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');
     }
 }
 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;
 }