You are here

public function SearchApiAttachmentsViewsHandlerAttachmentsFilter::query in Search API attachments 7

Add this filter to the query.

Due to the nature of fapi, the value and the operator have an unintended level of indirection. You will find them in $this->operator and $this->value respectively.

Overrides views_handler_filter::query

File

includes/views/search_api_attachments_views_handler_attachments_filter.inc, line 70
Contains SearchApiAttachmentsViewsHandlerAttachmentsFilter.

Class

SearchApiAttachmentsViewsHandlerAttachmentsFilter
Views filter handler class to filter attachments results.

Code

public function query() {
  if (empty($this->value[0])) {
    return;
  }

  // Loop through all defined fields and remove those starting by
  // 'attachments_' prefix.
  $fields = $this->query
    ->getFields();
  if (!empty($fields)) {
    foreach ($fields as $key => $field_name) {
      $prefix = 'attachments_';
      if (strpos($field_name, $prefix) === 0) {
        unset($fields[$key]);
      }
    }
    $this->query
      ->fields($fields);
  }
}