function features_var_export in Features 7
Same name and namespace in other branches
- 6 features.export.inc \features_var_export()
- 7.2 features.export.inc \features_var_export()
Export var function -- from Views.
13 calls to features_var_export()
- features_detect_overrides in ./
features.export.inc - Detect differences between DB and code components of a feature.
- features_get_signature in ./
features.export.inc - Wrapper around features_get_[storage] to return an md5hash of a normalized defaults/normal object array. Can be used to compare normal/default states of a module's component.
- features_translatables_export in ./
features.export.inc - Helper function to return an array of t()'d translatables strings. Useful for providing a separate array of translatables with your export so that string extractors like potx can detect them.
- field_features_export_render in includes/
features.field.inc - Implements hook_features_export_render().
- filter_features_export_render in includes/
features.filter.inc - Implements hook_features_export_render().
File
- ./
features.export.inc, line 466
Code
function features_var_export($var, $prefix = '', $init = TRUE) {
if (is_object($var)) {
$output = method_exists($var, 'export') ? $var
->export() : features_var_export((array) $var, '', FALSE);
}
else {
if (is_array($var)) {
if (empty($var)) {
$output = 'array()';
}
else {
$output = "array(\n";
foreach ($var as $key => $value) {
// Using normal var_export on the key to ensure correct quoting.
$output .= " " . var_export($key, TRUE) . " => " . features_var_export($value, ' ', FALSE) . ",\n";
}
$output .= ')';
}
}
else {
if (is_bool($var)) {
$output = $var ? 'TRUE' : 'FALSE';
}
else {
if (is_string($var) && strpos($var, "\n") !== FALSE) {
// Replace line breaks in strings with a token for replacement
// at the very end. This protects whitespace in strings from
// unintentional indentation.
$var = str_replace("\n", "***BREAK***", $var);
$output = var_export($var, TRUE);
}
else {
$output = var_export($var, TRUE);
}
}
}
}
if ($prefix) {
$output = str_replace("\n", "\n{$prefix}", $output);
}
if ($init) {
$output = str_replace("***BREAK***", "\n", $output);
}
return $output;
}