function ctools_var_export

cis7 export.inc ctools_var_export($var, $prefix = '')
cle7 export.inc ctools_var_export($var, $prefix = '')
elmsmedia7 export.inc ctools_var_export($var, $prefix = '')
icor7 export.inc ctools_var_export($var, $prefix = '')
meedjum_blog7 export.inc ctools_var_export($var, $prefix = '')
mooc7 export.inc ctools_var_export($var, $prefix = '')

Export a field.

This is a replacement for var_export(), allowing us to more nicely format exports. It will recurse down into arrays and will try to properly export bools when it can, though PHP has a hard time with this since they often end up as strings or ints.

7 calls to ctools_var_export()
backup_migrate_ui_export_form in sites/all/modules/ulmus/backup_migrate/backup_migrate.module
Convert an item to an 'exportable'.
context_export in sites/all/modules/ulmus/context/context.module
Exports the specified context.
ctools_component_features_export_render in sites/all/modules/ulmus/features/includes/features.ctools.inc
Master implementation of hook_features_export_render() for all ctools components.
ctools_export_object in sites/all/modules/ulmus/ctools/includes/export.inc
Export an object into code.
variable_features_export_render in sites/all/modules/ulmus/strongarm/strongarm.module
Implements hook_features_export_render().

... See full list

1 string reference to 'ctools_var_export'
backup_migrate_ui_export_form in sites/all/modules/ulmus/backup_migrate/backup_migrate.module
Convert an item to an 'exportable'.

File

sites/all/modules/ulmus/ctools/includes/export.inc, line 863
Contains code to make it easier to have exportable objects.

Code

function ctools_var_export($var, $prefix = '') {
  if (is_array($var)) {
    if (empty($var)) {
      $output = 'array()';
    }
    else {
      $output = "array(\n";
      foreach ($var as $key => $value) {
        $output .= $prefix . "  " . ctools_var_export($key) . " => " . ctools_var_export($value, $prefix . '  ') . ",\n";
      }
      $output .= $prefix . ')';
    }
  }
  else if (is_object($var) && get_class($var) === 'stdClass') {
    // var_export() will export stdClass objects using an undefined
    // magic method __set_state() leaving the export broken. This
    // workaround avoids this by casting the object as an array for
    // export and casting it back to an object when evaluated.
    $output = '(object) ' . ctools_var_export((array) $var, $prefix);
  }
  else if (is_bool($var)) {
    $output = $var ? 'TRUE' : 'FALSE';
  }
  else {
    $output = var_export($var, TRUE);
  }

  return $output;
}