public function SearchApiAlterFileEntityPublic::alterItems in Search API 7
Alter items before indexing.
Items which are removed from the array won't be indexed, but will be marked as clean for future indexing. This could for instance be used to implement some sort of access filter for security purposes (e.g., don't index unpublished nodes or comments).
Parameters
array $items: An array of items to be altered, keyed by item IDs.
Overrides SearchApiAlterCallbackInterface::alterItems
File
- includes/
callback_file_entity_public.inc, line 26 - Contains SearchApiAlterFileEntityPublic.
Class
- SearchApiAlterFileEntityPublic
- Excludes file entities in the private folder from being indexed.
Code
public function alterItems(array &$items) {
$multi_types = $this
->isMultiEntityIndex($this->index);
foreach ($items as $id => $item) {
$file = $item;
if ($multi_types) {
if ($item->item_type !== 'file') {
continue;
}
$file = $item->file;
}
if (empty($file->uri) || substr($file->uri, 0, 10) === 'private://') {
unset($items[$id]);
}
}
}