function _features_sanitize in Features 6
Same name and namespace in other branches
- 7.2 features.export.inc \_features_sanitize()
- 7 features.export.inc \_features_sanitize()
"Sanitizes" an array recursively, performing two key operations:
- Sort an array by its keys (assoc) or values (non-assoc)
- Remove any null or empty values for associative arrays (array_filter()).
2 calls to _features_sanitize()
- 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.
File
- ./
features.export.inc, line 839
Code
function _features_sanitize(&$array) {
if (is_array($array)) {
$is_assoc = array_keys($array) !== range(0, count($array) - 1);
if ($is_assoc) {
ksort($array);
$array = array_filter($array);
}
else {
sort($array);
}
foreach ($array as $k => $v) {
if (is_array($v)) {
_features_sanitize($array[$k]);
}
}
}
}