function search_api_views_search_api_index_update in Search API 7
Implements hook_search_api_index_update().
File
- contrib/
search_api_views/ search_api_views.module, line 28 - Integrates the Search API with Views.
Code
function search_api_views_search_api_index_update(SearchApiIndex $index) {
// Check whether index was disabled.
$is_enabled = $index->enabled;
$was_enabled = $index->original->enabled;
if (!$is_enabled && $was_enabled) {
_search_api_views_index_unavailable($index);
return;
}
// Check whether the indexed fields changed.
$old_fields = $index->original->options + array(
'fields' => array(),
);
$old_fields = $old_fields['fields'];
$new_fields = $index->options + array(
'fields' => array(),
);
$new_fields = $new_fields['fields'];
// If the index was enabled or its fields changed, invalidate the Views cache.
if ($is_enabled != $was_enabled || $old_fields != $new_fields) {
views_invalidate_cache();
}
}