class drush_outputformat_var_export

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

Output formatter 'var_export'

Note: this class is also used by format 'config'

Hierarchy

Expanded class hierarchy of drush_outputformat_var_export

Members

File

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

View source
class drush_outputformat_var_export extends drush_outputformat {
  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;
  }
}