class drush_outputformat_variables

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

Output formatter 'variables'

Hierarchy

Expanded class hierarchy of drush_outputformat_variables

Members

File

commands/core/outputformat/variables.inc, line 28

View source
class drush_outputformat_variables extends drush_outputformat {
  function validate() {
    $metadata = $this->engine_config;
    $this->sub_engine = drush_load_engine('outputformat', 'var_export', $metadata);
    if (!is_object($this->sub_engine)) {
      return FALSE;
    }
    return TRUE;
  }

  function format($data, $metadata) {
    $output = '';
    if (is_array($data)) {
      foreach ($data as $variable_name => $section) {
        foreach ($section as $label => $value) {
          $metameta = array(
            'variable-name' => $variable_name,
            'label' => $label,
          );
          $formatted_item = $this->sub_engine->process($value, $metameta);
          if ($formatted_item === FALSE) {
            return FALSE;
          }
          $output .= $formatted_item;
          $output .= "\n";
        }
      }
    }
    return $output;
  }
}