You are here

function facetapi_query_type_hooks_invoke in Facet API 6

Invokes query type callbacks for all facets.

Query type hooks are generally used to process facet data and apply filters to the query for the selectd items. The query type is set in the facet definition, and the adapter module's hook_facetapi_query_QUERY_TYPE_prepare() implementation is invoked for each facet being built by the adapter.

Parameters

$searcher: A string containing the machine readable name of the searcher module.

&$data: A mixed value containing any data that needs to be altered. For example, this may be the "params" array for Apache Solr or the query object for Search Lucene API.

...: Any additional parameters passed to the hook.

2 calls to facetapi_query_type_hooks_invoke()
facetapi_apachesolr_apachesolr_prepare_query in contrib/facetapi_apachesolr/facetapi_apachesolr.module
Implementation of hook_apachesolr_prepare_query().
facetapi_luceneapi_luceneapi_query_alter in contrib/facetapi_luceneapi/facetapi_luceneapi.module
Implementation of hook_apachesolr_prepare_query().

File

./facetapi.module, line 863
An abstracted facet API that can be used by various search backens.

Code

function facetapi_query_type_hooks_invoke($searcher, &$data) {
  if ($adapter = facetapi_adapter_load($searcher)) {
    $facets = facetapi_enabled_facets_get($searcher);
    foreach ($facets as $facet) {
      $hook = 'facetapi_query_' . $facet['query type'] . '_prepare';
      if (module_hook($adapter
        ->getModule(), $hook)) {
        $function = $adapter
          ->getModule() . '_' . $hook;
        $args = func_get_args();
        $params = array_merge(array(
          $adapter,
          $facet,
          &$data,
        ), array_slice($args, 2));
        call_user_func_array($function, $params);
      }
    }
  }
}