message.inc

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

Classes

Namesort descending Description
drush_outputformat_message Output formatter 'message'

File

commands/core/outputformat/message.inc
View source
  1. <?php
  2. /**
  3. * Output formatter 'message'
  4. *
  5. * @param $data
  6. * The parameters for the render data
  7. * @param $metadata
  8. * 'message-template' - Provides the template string to use with dt().
  9. *
  10. * Code:
  11. *
  12. * return array('a' => 1, 'b' => 2);
  13. *
  14. * Given 'message-template' == 'The first is !a and the second is !b',
  15. * output with --format=message:
  16. *
  17. * The first is 1 and the second is 2
  18. */
  19. class drush_outputformat_message extends drush_outputformat {
  20. function format($data, $metadata) {
  21. $result = '';
  22. if (isset($metadata['message-template'])) {
  23. foreach ($data as $key => $value) {
  24. $data_for_dt['!' . $key] = $value;
  25. }
  26. $result = dt($metadata['message-template'], $data_for_dt);
  27. }
  28. return $result;
  29. }
  30. }