function drush_select_fields

8.0.x output.inc drush_select_fields($all_field_labels, $fields, $strict = TRUE)
6.x output.inc drush_select_fields($all_field_labels, $fields, $strict = TRUE)
7.x output.inc drush_select_fields($all_field_labels, $fields, $strict = TRUE)
master output.inc drush_select_fields($all_field_labels, $fields, $strict = TRUE)

Select the fields that should be used.

Related topics

1 call to drush_select_fields()
drush_handle_command_output in includes/command.inc
Convert the structured output array provided from the Drush command into formatted output. Output is only printed for commands that define 'default-format' &/or 'default-pipe-format'; all other commands are expected to do…

File

includes/output.inc, line 363

Code

function drush_select_fields($all_field_labels, $fields, $strict = TRUE) {
  $field_labels = array();
  foreach ($fields as $field) {
    if (array_key_exists($field, $all_field_labels)) {
      $field_labels[$field] = $all_field_labels[$field];
    }
    else {
      // Allow the user to select fields via their human-readable names.
      // This is less convenient than the field name (since the human-readable
      // names may contain spaces, and must therefore be quoted), but these are
      // the values that the user sees in the command output. n.b. the help
      // text lists fields by their more convenient machine names.
      $key = array_search(strtolower($field), array_map('strtolower', $all_field_labels));
      if ($key !== FALSE) {
        $field_labels[$key] = $all_field_labels[$key];
      }
      elseif (!$strict) {
        $field_labels[$field] = $field;
      }
    }
  }
  return $field_labels;
}