class SearchApiAlterFileEntityPublic in Search API 7
Excludes file entities in the private folder from being indexed.
Hierarchy
- class \SearchApiAbstractAlterCallback implements SearchApiAlterCallbackInterface
Expanded class hierarchy of SearchApiAlterFileEntityPublic
1 string reference to 'SearchApiAlterFileEntityPublic'
File
- includes/
callback_file_entity_public.inc, line 11 - Contains SearchApiAlterFileEntityPublic.
View source
class SearchApiAlterFileEntityPublic extends SearchApiAbstractAlterCallback {
/**
* {@inheritdoc}
*/
public function supportsIndex(SearchApiIndex $index) {
if ($this
->isMultiEntityIndex($index)) {
return in_array('file', $index->options['datasource']['types']);
}
return $index
->getEntityType() === 'file';
}
/**
* {@inheritdoc}
*/
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]);
}
}
}
}