public function SearchApiTestService::indexItems in Search API 7
Implements SearchApiServiceInterface::indexItems().
Indexes items by storing their IDs in the server's options.
If the "search_api_test_indexing_break" variable is set, the item with that ID will not be indexed.
Overrides SearchApiServiceInterface::indexItems
File
- tests/
search_api_test.module, line 279 - Test functions and classes for testing the Search API.
Class
- SearchApiTestService
- Test service class.
Code
public function indexItems(SearchApiIndex $index, array $items) {
$this
->checkErrorState();
// Refuse to index the item with the same ID as the
// "search_api_test_indexing_break" variable, if it is set.
$exclude = variable_get('search_api_test_indexing_break', 8);
foreach ($items as $id => $item) {
if ($id == $exclude) {
unset($items[$id]);
}
}
$ids = array_keys($items);
$this->options += array(
'indexes' => array(),
);
$this->options['indexes'] += array(
$index->machine_name => array(),
);
$this->options['indexes'][$index->machine_name] += drupal_map_assoc($ids);
asort($this->options['indexes'][$index->machine_name]);
$this->server
->save();
return $ids;
}