Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Fixes #1589: @executeInDrupalVm not respected during invokeCommand. #1595

Merged
merged 5 commits into from
Jun 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/Robo/Application.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Acquia\Blt\Robo;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Application as ConsoleApplication;

/**
* Class Application
* @package Acquia\Blt\Robo
*/
class Application extends ConsoleApplication {

/**
* @param \Symfony\Component\Console\Command\Command $command
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
*
* @return int
* The exit code.
*/
public function runCommand(Command $command, InputInterface $input, OutputInterface $output) {
return $this->doRunCommand($command, $input, $output);
}

}
4 changes: 2 additions & 2 deletions src/Robo/Blt.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use Robo\Config\Config;
use Robo\Robo;
use Robo\Runner as RoboRunner;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -224,7 +223,8 @@ public function configureContainer($container) {
* The exiting status code of the application
*/
public function run(InputInterface $input, OutputInterface $output) {
$status_code = $this->runner->run($input, $output, NULL, $this->commands);
$application = $this->getContainer()->get('application');
$status_code = $this->runner->run($input, $output, $application, $this->commands);

return $status_code;
}
Expand Down
7 changes: 4 additions & 3 deletions src/Robo/BltTasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,17 @@ protected function invokeCommand($command_name, array $args = []) {
return 0;
}

/** @var \Robo\Application $application */
/** @var \Acquia\Blt\Robo\Application $application */
$application = $this->getContainer()->get('application');
$command = $application->find($command_name);

$input = new ArrayInput($args);
$prefix = str_repeat(">", $this->invokeDepth);
$this->output->writeln("<comment>$prefix $command_name</comment>");
$returnCode = $command->run($input, $this->output());
$return_code = $application->runCommand($command, $input, $this->output());
$this->invokeDepth--;

return $returnCode;
return $return_code;
}

/**
Expand Down
10 changes: 10 additions & 0 deletions src/Robo/Hooks/CommandEventHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function executeInDrupalVm(ConsoleCommandEvent $event) {
if (method_exists($command, 'getAnnotationData')) {
/* @var \Consolidation\AnnotatedCommand\AnnotationData */
$annotation_data = $event->getCommand()->getAnnotationData();
$this->warnIfDrupalVmNotRunning();
if ($annotation_data->has('executeInDrupalVm') && $this->shouldExecuteInDrupalVm()) {
$event->disableCommand();
$args = $this->getCliArgs();
Expand Down Expand Up @@ -95,4 +96,13 @@ protected function shouldExecuteInDrupalVm() {
&& !$this->getInspector()->isVmCli();
}

/**
* Emits a warning if Drupal VM is initialized but not running.
*/
protected function warnIfDrupalVmNotRunning() {
if ($this->getInspector()->isDrupalVmLocallyInitialized() && !$this->getInspector()->isDrupalVmBooted()) {
$this->logger->warning("Drupal VM is locally initialized, but it not running.");
}
}

}