4 * Output formatter 'variables'
7 * The $data parameter is expected to be a nested array of key / value pairs.
8 * The top-level key becomes the variable name, $metadata['variable-name'],
9 * and the key on the inner-level items becomes the array label,
10 * $metadata['label']. These items are then rendered by the 'var_export' formatter.
17 * "a" => array("b" => 2, "c" => 3),
18 * "d" => array("e" => 5, "f" => 6)
21 * Output with --format=variables:
28 class drush_outputformat_variables extends drush_outputformat {
30 $metadata = $this->engine_config;
31 $this->sub_engine = drush_load_engine('outputformat', 'var_export', $metadata);
32 if (!is_object($this->sub_engine)) {
38 function format($data, $metadata) {
40 if (is_array($data)) {
41 foreach ($data as $variable_name => $section) {
42 foreach ($section as $label => $value) {
44 'variable-name' => $variable_name,
47 $formatted_item = $this->sub_engine->process($value, $metameta);
48 if ($formatted_item === FALSE) {
51 $output .= $formatted_item;