You are here

function features_sanitize in Features 7.2

Helper function to "sanitize" an array or object.

Converts everything to an array, sorts the keys, removes recursion.

@todo Needs unit tests. @todo A better name might be "normalize", not "sanitize".

Parameters

array|object $array: The object or array to "sanitize". After this call, this variable will be an array.

string $component: (optional) Name of a component type, e.g. "field_instance".

bool $remove_empty: (optional) If TRUE, remove null or empty values for assoc arrays.

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
Gets an md5 signature for a the state of an object in code or database.

File

./features.export.inc, line 1477
Contains functions that export configuration into feature modules.

Code

function features_sanitize(&$array, $component = NULL, $remove_empty = TRUE) {
  $array = features_remove_recursion($array);
  if (isset($component)) {
    $ignore_keys = _features_get_ignore_keys($component);

    // Remove keys to be ignored.
    if (count($ignore_keys)) {
      _features_remove_ignores($array, $ignore_keys);
    }
  }
  _features_sanitize($array, $remove_empty);
}