function _search_api_entity_datasource_bundle_change in Search API 7
Reacts to a change in the bundle of an entity.
Used as a helper function in search_api_entity_update().
Parameters
$type: The entity's type.
$id: The entity's ID.
$old_bundle: The entity's previous bundle.
$new_bundle: The entity's new bundle.
1 call to _search_api_entity_datasource_bundle_change()
- search_api_entity_update in ./
search_api.module - Implements hook_entity_update().
File
- ./
search_api.module, line 3326 - Provides a flexible framework for implementing search services.
Code
function _search_api_entity_datasource_bundle_change($type, $id, $old_bundle, $new_bundle) {
$controller = search_api_get_datasource_controller($type);
$conditions = array(
'enabled' => 1,
'item_type' => $type,
'read_only' => 0,
);
foreach (search_api_index_load_multiple(FALSE, $conditions) as $index) {
if (!empty($index->options['datasource']['bundles'])) {
$bundles = drupal_map_assoc($index->options['datasource']['bundles']);
if (empty($bundles[$new_bundle]) != empty($bundles[$old_bundle])) {
if (empty($bundles[$new_bundle])) {
$controller
->trackItemDelete(array(
$id,
), array(
$index,
));
}
else {
$controller
->trackItemInsert(array(
$id,
), array(
$index,
));
}
}
}
}
}