function search_api_entity_update in Search API 7
Same name and namespace in other branches
- 8 search_api.module \search_api_entity_update()
Implements hook_entity_update().
This is implemented on behalf of the SearchApiEntityDataSourceController datasource controller and calls search_api_track_item_change() for the updated items.
It also checks whether the entity's bundle changed and acts accordingly.
See also
search_api_search_api_item_type_info()
File
- ./
search_api.module, line 896 - Provides a flexible framework for implementing search services.
Code
function search_api_entity_update($entity, $type) {
// We only react on entity operations for types with property information, as
// we don't provide search integration for the others.
if (!entity_get_property_info($type)) {
return;
}
list($id, , $new_bundle) = entity_extract_ids($type, $entity);
// Check if the entity's bundle changed.
if (!empty($entity->original)) {
list(, , $old_bundle) = entity_extract_ids($type, $entity->original);
if ($new_bundle != $old_bundle) {
_search_api_entity_datasource_bundle_change($type, $id, $old_bundle, $new_bundle);
}
}
if (isset($id)) {
search_api_track_item_change($type, array(
$id,
));
$combined_id = $type . '/' . $id;
search_api_track_item_change('multiple', array(
$combined_id,
));
}
}