function drush_outputformat_var_export::format

8.0.x var_export.inc drush_outputformat_var_export::format($input, $metadata)
6.x var_export.inc drush_outputformat_var_export::format($input, $metadata)
7.x var_export.inc drush_outputformat_var_export::format($input, $metadata)
master var_export.inc drush_outputformat_var_export::format($input, $metadata)

Overrides drush_outputformat::format

File

commands/core/outputformat/var_export.inc, line 49

Class

drush_outputformat_var_export
Output formatter 'var_export'

Code

function format($input, $metadata) {
  if (isset($metadata['label'])) {
    $variable_name = isset($metadata['variable-name']) ? $metadata['variable-name'] : 'variables';
    $variable_name = preg_replace("/[^a-zA-Z0-9_-]/", "", str_replace(' ', '_', $variable_name));
    $label = $metadata['label'];
    $label_template = (isset($metadata['label-template'])) ? $metadata['label-template'] : '$!variable["!label"] = !value;';
    $output = dt($label_template, array('!variable' => $variable_name, '!label' => $label, '!value' => var_export($input, TRUE)));
  }
  else {
    $output = drush_var_export($input);
  }
  return $output;
}