You are here

public function SearchApiViewsHandlerArgument::query in Search API 7

Set up the query for this argument.

The argument sent may be found at $this->argument.

Overrides views_handler_argument::query

1 call to SearchApiViewsHandlerArgument::query()
SearchApiViewsHandlerArgumentString::query in contrib/search_api_views/includes/handler_argument_string.inc
Set up the query for this argument.
5 methods override SearchApiViewsHandlerArgument::query()
SearchApiViewsHandlerArgumentDate::query in contrib/search_api_views/includes/handler_argument_date.inc
Set up the query for this argument.
SearchApiViewsHandlerArgumentFulltext::query in contrib/search_api_views/includes/handler_argument_fulltext.inc
Set up the query for this argument.
SearchApiViewsHandlerArgumentMoreLikeThis::query in contrib/search_api_views/includes/handler_argument_more_like_this.inc
Set up the query for this argument.
SearchApiViewsHandlerArgumentString::query in contrib/search_api_views/includes/handler_argument_string.inc
Set up the query for this argument.
SearchApiViewsHandlerArgumentTaxonomyTerm::query in contrib/search_api_views/includes/handler_argument_taxonomy_term.inc
Set up the query for this argument.

File

contrib/search_api_views/includes/handler_argument.inc, line 114
Contains SearchApiViewsHandlerArgument.

Class

SearchApiViewsHandlerArgument
Views argument handler class for handling all non-fulltext types.

Code

public function query($group_by = FALSE) {
  if (empty($this->value)) {
    if (!empty($this->options['break_phrase'])) {
      views_break_phrase($this->argument, $this);
    }
    else {
      $this->value = array(
        $this->argument,
      );
    }
  }
  $operator = empty($this->options['not']) ? '=' : '<>';
  if (count($this->value) > 1) {
    $filter = $this->query
      ->createFilter(drupal_strtoupper($this->operator));

    // $filter will be NULL if there were errors in the query.
    if ($filter) {
      foreach ($this->value as $value) {
        $filter
          ->condition($this->real_field, $value, $operator);
      }
      $this->query
        ->filter($filter);
    }
  }
  else {
    $this->query
      ->condition($this->real_field, reset($this->value), $operator);
  }
}