csv_or_string.inc

  1. 8.0.x commands/core/outputformat/csv_or_string.inc
  2. 6.x commands/core/outputformat/csv_or_string.inc
  3. 7.x commands/core/outputformat/csv_or_string.inc
  4. master commands/core/outputformat/csv_or_string.inc

Classes

Namesort descending Description
drush_outputformat_csv_or_string Output formatter 'csv-or-string'

File

commands/core/outputformat/csv_or_string.inc
View source
  1. <?php
  2. /**
  3. * Output formatter 'csv-or-string'
  4. *
  5. * @param $data
  6. * The render data may be either a string or an array
  7. * - string: printed as-is, without quotes.
  8. * - array: the value is printed as a csv list.
  9. *
  10. * This is a helper format for handling nested csv lists.
  11. */
  12. class drush_outputformat_csv_or_string extends drush_outputformat {
  13. function format($data, $metadata) {
  14. // If the data is an array, print it as a comma-separated list
  15. if (is_array($data)) {
  16. return drush_format($data, $metadata, 'csv');
  17. }
  18. return (string)$data;
  19. }
  20. }