You are here

class SearchApiAlterFileEntityPublic in Search API 7

Excludes file entities in the private folder from being indexed.

Hierarchy

Expanded class hierarchy of SearchApiAlterFileEntityPublic

1 string reference to 'SearchApiAlterFileEntityPublic'
search_api_search_api_alter_callback_info in ./search_api.module
Implements hook_search_api_alter_callback_info().

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]);
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SearchApiAbstractAlterCallback::$index protected property The index whose items will be altered.
SearchApiAbstractAlterCallback::$options protected property The configuration options for this callback, if it has any.
SearchApiAbstractAlterCallback::configurationForm public function Implements SearchApiAlterCallbackInterface::configurationForm(). Overrides SearchApiAlterCallbackInterface::configurationForm 6
SearchApiAbstractAlterCallback::configurationFormSubmit public function Implements SearchApiAlterCallbackInterface::configurationFormSubmit(). Overrides SearchApiAlterCallbackInterface::configurationFormSubmit 4
SearchApiAbstractAlterCallback::configurationFormValidate public function Implements SearchApiAlterCallbackInterface::configurationFormValidate(). Overrides SearchApiAlterCallbackInterface::configurationFormValidate 1
SearchApiAbstractAlterCallback::isMultiEntityIndex protected function Determines whether the given index contains multiple types of entities.
SearchApiAbstractAlterCallback::propertyInfo public function Implements SearchApiAlterCallbackInterface::propertyInfo(). Overrides SearchApiAlterCallbackInterface::propertyInfo 6
SearchApiAbstractAlterCallback::__construct public function Implements SearchApiAlterCallbackInterface::__construct(). Overrides SearchApiAlterCallbackInterface::__construct 1
SearchApiAlterFileEntityPublic::alterItems public function Alter items before indexing. Overrides SearchApiAlterCallbackInterface::alterItems
SearchApiAlterFileEntityPublic::supportsIndex public function Implements SearchApiAlterCallbackInterface::supportsIndex(). Overrides SearchApiAbstractAlterCallback::supportsIndex