function annotationcommand_adapter_build_input

master annotationcommand_adapter.inc annotationcommand_adapter_build_input($console_command, $userArgs)

TODO: This could probably just be a DrushInputAdapter now.

1 call to annotationcommand_adapter_build_input()
annotationcommand_adapter_run_console_command in includes/annotationcommand_adapter.inc
This function is set as the $command['callback'] for Symfony Console commands e.g. those provided by Drupal 8 modules. When the DRUSH_SYMFONY environment variable is set, these will be called via Symfony's Application::run()…

File

includes/annotationcommand_adapter.inc, line 150
annotationcommand_adapter.inc

Code

function annotationcommand_adapter_build_input($console_command, $userArgs) {
  $args =[];
  $defaultOptions =[];
  $definition = $console_command->getDefinition();
  $inputArguments = $definition->getArguments();
  foreach ($inputArguments as $key => $inputOption) {
    $value = array_shift($userArgs);
    if (!isset($value)) {
      $value = $inputOption->getDefault();
    }
    $args[$key] = $value;
  }
  $inputOptions = $definition->getOptions();
  foreach ($inputOptions as $option => $inputOption) {
    $defaultOptions[$option] = $inputOption->getDefault();
  }
  foreach ($defaultOptions as $option => $value) {
    $args["--$option"] = drush_get_option($option, $value);
  }
  // TODO: Need to add global options. Note that ArrayInput is validated.
  $input = new ArrayInput($args, $definition);
  return $input;
}