You are here

public function CliWorkaroundCommands::preCommand in Tome 8

This tricks "drush php" into working for Symfony console commands.

@hook pre-command php:cli

File

modules/tome_base/src/Commands/CliWorkaroundCommands.php, line 24

Class

CliWorkaroundCommands
Contains logic for working around Drush bugs.

Namespace

Drupal\tome_base\Commands

Code

public function preCommand(CommandData $commandData) {
  foreach (Drush::getApplication()
    ->all('tome') as $name => $command) {
    if (!$command instanceof AnnotatedCommand) {
      $dupe_command = new AnnotatedCommand($name);
      $dupe_command
        ->setDefinition($command
        ->getDefinition());
      Drush::getApplication()
        ->add($dupe_command);
    }
  }
}