Skip to content

Commit

Permalink
If the legacy Drush runner does not find a command, then try to run a…
Browse files Browse the repository at this point in the history
… command via the Symfony Console Application.
  • Loading branch information
greg-1-anderson committed Mar 30, 2016
1 parent 027c170 commit 0057d55
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
4 changes: 4 additions & 0 deletions includes/preflight.inc
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ function drush_main() {
}
}
else {
// TODO: If 'DRUSH_SYMFONY' is set, then disable the legacy command
// runner, and use only the Symfony Application. n.b. the legacy runner
// will also try to run commands via the Symfony Application runner if
// it cannot find a matching legacy Drush command.
if (getenv('DRUSH_SYMFONY')) {
// Get the application and run it.
// TODO: We need a new way to handle @alias arguments,
Expand Down
27 changes: 22 additions & 5 deletions lib/Drush/Boot/BaseBoot.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ function bootstrap_and_dispatch() {
// Dispatch the command(s).
$return = drush_dispatch($command);

// Prevent a '1' at the end of the output.
if ($return === TRUE) {
$return = '';
}

if (drush_get_context('DRUSH_DEBUG') && !drush_get_context('DRUSH_QUIET')) {
// @todo Create version independant wrapper around Drupal timers. Use it.
drush_print_timers();
Expand All @@ -89,11 +84,33 @@ function bootstrap_and_dispatch() {
}
}

// TODO: If we could not find a legacy Drush command, try running a
// command via the Symfony application. See also drush_main() in preflight.inc;
// ultimately, the Symfony application should be called from there.
if (!$command_found && isset($command)) {
$container = \Drush::getContainer();
$application = $container->get('application');
$args = drush_get_arguments();
if (count($args)) {
$name = $args[0];
if ($application->find($name)) {
$command_found = true;
$application->run();
}
}
}

if (!$command_found) {
// If we reach this point, command doesn't fit requirements or we have not
// found either a valid or matching command.
$this->report_command_error($command);
}

// Prevent a '1' at the end of the output.
if ($return === TRUE) {
$return = '';
}

return $return;
}

Expand Down

0 comments on commit 0057d55

Please sign in to comment.