function example_data_type_conversion in Search API 7
Convert a raw value from an entity to a custom data type.
This function will be called for fields of the specific data type to convert all individual values of the field to the correct format.
Parameters
mixed $value: The raw, single value, as extracted from an entity wrapper.
string $original_type: The original Entity API type of the value.
string $type: The custom data type to which the value should be converted. Can be ignored if the callback is only used for a single data type.
Return value
mixed|null The converted value, if a conversion could be executed. NULL otherwise.
See also
hook_search_api_data_type_info()
1 string reference to 'example_data_type_conversion'
- hook_search_api_data_type_info in ./
search_api.api.php - Define new data types for indexed properties.
File
- ./
search_api.api.php, line 600 - Hooks provided by the Search API module.
Code
function example_data_type_conversion($value, $original_type, $type) {
if ($type === 'example_type') {
// The example_type type apparently requires a rather complex data format.
return array(
'value' => $value,
'original' => $original_type,
);
}
// Someone used this callback for another, unknown type. Return NULL.
// (Normally, you can just assume that the/a correct type is given.)
return NULL;
}