yaml.inc

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

Constants

Namesort descending Description
DRUSH_YAML_VERSION

Classes

Namesort descending Description
drush_outputformat_yaml Output formatter 'yaml'

File

commands/core/outputformat/yaml.inc
View source
  1. <?php
  2. define('DRUSH_YAML_VERSION', '2.2.1');
  3. if (!class_exists('Symfony\Component\Yaml\Dumper')) {
  4. // For Drush PSR-0 and Composer information, see http://drupal.org/node/1316322.
  5. $path = DRUSH_BASE_PATH . '/lib/Yaml-' . DRUSH_YAML_VERSION;
  6. require_once "$path/Dumper.php";
  7. require_once "$path/Inline.php";
  8. require_once "$path/Escaper.php";
  9. }
  10. use Symfony\Component\Yaml\Dumper;
  11. /**
  12. * Output formatter 'yaml'
  13. *
  14. * @param $data
  15. * The $data parameter is rendered in yaml
  16. * @param $metadata
  17. *
  18. * Code:
  19. *
  20. */
  21. class drush_outputformat_yaml extends drush_outputformat {
  22. function format($input, $metadata) {
  23. $dumper = new Dumper();
  24. // Set Yaml\Dumper's default indentation for nested nodes/collections to
  25. // 2 spaces for consistency with Drupal coding standards.
  26. $dumper->setIndentation(2);
  27. // The level where you switch to inline YAML is set to PHP_INT_MAX to
  28. // ensure this does not occur.
  29. $output = $dumper->dump($input, PHP_INT_MAX, NULL, NULL, TRUE);
  30. return $output;
  31. }
  32. }