function _search_api_rules_action_index in Search API 7
Rules action for indexing an item.
1 string reference to '_search_api_rules_action_index'
- search_api_rules_action_info in ./
search_api.rules.inc - Implements hook_rules_action_info().
File
- ./
search_api.rules.inc, line 54 - Search API Rules integration.
Code
function _search_api_rules_action_index(EntityDrupalWrapper $wrapper, SearchApiIndex $index = NULL, $index_immediately = TRUE) {
// If we do not have an index, we need to guess the item type to use.
// @todo Since this can only be used with entities anyways, we can just loop
// over the item type information and use all types with that entity type.
$type = $wrapper
->type();
$item_ids = array(
$wrapper
->getIdentifier(),
);
if (empty($index) && !$index_immediately) {
search_api_track_item_change($type, $item_ids);
return;
}
if ($index) {
$type = $index->item_type;
$indexes = array(
$index,
);
}
else {
$conditions = array(
'enabled' => 1,
'item_type' => $type,
'read_only' => 0,
);
$indexes = search_api_index_load_multiple(FALSE, $conditions);
if (!$indexes) {
return;
}
}
if ($index_immediately) {
foreach ($indexes as $index) {
search_api_index_specific_items_delayed($index, $item_ids);
}
}
else {
search_api_get_datasource_controller($type)
->trackItemChange($item_ids, $indexes);
}
}