function _drush_backend_classify_options

8.0.x backend.inc _drush_backend_classify_options($site_record, $command_options, &$backend_options)
6.x backend.inc _drush_backend_classify_options($site_record, $command_options, &$backend_options)
7.x backend.inc _drush_backend_classify_options($site_record, $command_options, &$backend_options)
5.x backend.inc _drush_backend_classify_options($site_record, $command_options, &$backend_options)
master backend.inc _drush_backend_classify_options($site_record, $command_options, &$backend_options)

Take all of the values in the $command_options array, and place each of them into one of the following result arrays:

  • $post_options: options to be encoded as JSON and written to the standard input of the drush subprocess being executed.
  • $commandline_options: options to be placed on the command line of the drush subprocess.
  • $drush_global_options: the drush global options also go on the command line, but appear before the drush command name rather than after it.

Also, this function may modify $backend_options.

1 call to _drush_backend_classify_options()
drush_backend_invoke_concurrent in includes/backend.inc
Execute a new local or remote command in a new process.

File

includes/backend.inc, line 903
Drush backend API

Code

function _drush_backend_classify_options($site_record, $command_options, &$backend_options) {
  // In 'POST' mode (the default, remove everything (except the items marked 'never-post'
  // in the global option list) from the commandline options and put them into the post options.
  // The post options will be json-encoded and sent to the command via stdin
  $global_option_list = drush_get_global_options(FALSE); // These should be in the command line.
  $additional_global_options = array();
  if (array_key_exists('additional-global-options', $backend_options)) {
    $additional_global_options = $backend_options['additional-global-options'];
    $command_options += $additional_global_options;
  }
  $method_post = ((!array_key_exists('method', $backend_options)) || ($backend_options['method'] == 'POST'));
  $post_options = array();
  $commandline_options = array();
  $drush_global_options = array();
  $drush_local_options = array();
  $additional_backend_options = array();
  foreach ($site_record as $key => $value) {
    if (!in_array($key, drush_sitealias_site_selection_keys())) {
      if ($key[0] == '#') {
        $backend_options[$key] = $value;
      }
      if (!isset($command_options[$key])) {
        if (array_key_exists($key, $global_option_list)) {
          $command_options[$key] = $value;
        }
      }
    }
  }
  if (array_key_exists('drush-local-options', $backend_options)) {
    $drush_local_options = $backend_options['drush-local-options'];
    $command_options += $drush_local_options;
  }
  if (!empty($backend_options['backend']) && empty($backend_options['interactive']) && empty($backend_options['fork'])) {
    $drush_global_options['backend'] = '2';
  }
  foreach ($command_options as $key => $value) {
    $global = array_key_exists($key, $global_option_list);
    $propagate = TRUE;
    $special = FALSE;
    if ($global) {
      $propagate = (!array_key_exists('never-propagate', $global_option_list[$key]));
      $special = (array_key_exists('never-post', $global_option_list[$key]));
      if ($propagate) {
        // We will allow 'merge-pathlist' contexts to be propogated.  Right now
        // these are all 'local-context-only' options; if we allowed them to
        // propogate remotely, then we would need to get the right path separator
        // for the remote machine.
        if (is_array($value) && array_key_exists('merge-pathlist', $global_option_list[$key])) {
          $value = implode(PATH_SEPARATOR, $value);
        }
      }
    }
    // Just remove options that are designated as non-propagating
    if ($propagate === TRUE) {
      // In METHOD POST, move command options to post options
      if ($method_post && ($special === FALSE)) {
        $post_options[$key] = $value;
      }
      // In METHOD GET, ignore options with array values
      elseif (!is_array($value)) {
        if ($global || array_key_exists($key, $additional_global_options)) {
          $drush_global_options[$key] = $value;
        }
        else {
          $commandline_options[$key] = $value;
        }
      }
    }
  }
  return array($post_options, $commandline_options, $drush_global_options, $additional_backend_options);
}