You are here

function search_api_sanitize_field_value in Search API 7

Sanitizes the given field value(s).

Parameters

mixed $field_value: A scalar field value, or an array of field values.

callable $sanitize_callback: (optional) The callback to use for sanitizing a scalar value.

Return value

mixed The sanitized field value(s).

1 call to search_api_sanitize_field_value()
search_api_get_sanitized_field_values in ./search_api.module
Sanitizes field values returned from the server.

File

./search_api.module, line 3104
Provides a flexible framework for implementing search services.

Code

function search_api_sanitize_field_value($field_value, $sanitize_callback = 'check_plain') {
  if ($field_value === NULL) {
    return $field_value;
  }
  if (is_scalar($field_value)) {
    return call_user_func($sanitize_callback, $field_value);
  }
  foreach ($field_value as &$nested_value) {
    $nested_value = search_api_sanitize_field_value($nested_value, $sanitize_callback);
  }
  return $field_value;
}