4 * Output formatter 'var_export'
6 * Note: this class is also used by format 'config'
9 * The $data parameter is rendered with the php var_export() function
11 * 'label' - If present, prints "$variable['label'] = " prior to the data
12 * 'variable-name' - If present, provides an alternate name for $variable
13 * when labels are in use.
18 * "a" => array("b" => 2, "c" => 3),
19 * "d" => array("e" => 5, "f" => 6)
22 * Output with --format=var_export:
37 * Output with --format=config: (list of export)
39 * $config['a'] = array (
43 * $config['d'] = array (
48 class drush_outputformat_var_export extends drush_outputformat {
49 function format($input, $metadata) {
50 if (isset($metadata['label'])) {
51 $variable_name = isset($metadata['variable-name']) ? $metadata['variable-name'] : 'variables';
52 $variable_name = preg_replace("/[^a-zA-Z0-9_-]/", "", str_replace(' ', '_', $variable_name));
53 $label = $metadata['label'];
54 $label_template = (isset($metadata['label-template'])) ? $metadata['label-template'] : '$!variable["!label"] = !value;';
55 $output = dt($label_template, array('!variable' => $variable_name, '!label' => $label, '!value' => var_export($input, TRUE)));
58 $output = drush_var_export($input);