You are here

public function SearchApiFacetapiAdapter::getCurrentSearch in Search API 7

Helper method for getting a current search for this searcher.

Return value

array The first matching current search, in the form specified by search_api_current_search(). Or NULL, if no match was found.

3 calls to SearchApiFacetapiAdapter::getCurrentSearch()
SearchApiFacetapiAdapter::getResultCount in contrib/search_api_facetapi/plugins/facetapi/adapter.inc
Returns the number of total results found for the current search.
SearchApiFacetapiAdapter::getSearchKeys in contrib/search_api_facetapi/plugins/facetapi/adapter.inc
Returns the search keys.
SearchApiFacetapiAdapter::searchExecuted in contrib/search_api_facetapi/plugins/facetapi/adapter.inc
Returns a boolean flagging whether $this->_searcher executed a search.

File

contrib/search_api_facetapi/plugins/facetapi/adapter.inc, line 152
Classes used by the Facet API module.

Class

SearchApiFacetapiAdapter
Facet API adapter for the Search API module.

Code

public function getCurrentSearch() {

  // Even if this fails once, there might be a search query later in the page
  // request. We therefore don't store anything in $this->current_search in
  // case of failure, but just try again if the method is called again.
  if (!isset($this->current_search)) {
    $index_id = $this->info['instance'];

    // There is currently no way to configure the "current search" block to
    // show on a per-searcher basis as we do with the facets. Therefore we
    // cannot match it up to the correct "current search".
    // I suspect that http://drupal.org/node/593658 would help.
    // For now, just taking the first current search for this index. :-/
    foreach (search_api_current_search() as $search) {
      list($query) = $search;
      if ($query
        ->getIndex()->machine_name == $index_id) {
        $this->current_search = $search;
      }
    }
  }
  return $this->current_search;
}