Commit fef2313e authored by marthinal's avatar marthinal

#2612084 Added .module to use the hook alter

parent 6312c2c5
<?php
/**
* @file
* Contains core_search_facetapi.module
*/
use Drupal\Core\Database\Query\AlterableInterface;
/**
* Implements hook_query_TAG_alter(): tag search_$type with $type node_search.
*
* @param \Drupal\Core\Database\Query\AlterableInterface $query
*/
function facetapi_query_search_node_search_alter(AlterableInterface $query) {
// Obtain the Facet Source id for the current search.
$request = \Drupal::requestStack()->getMasterRequest();
$search_page = $request->attributes->get('entity');
/** @var \Drupal\facetapi\FacetManager\DefaultFacetManager $facet_manager */
$facet_manager = \Drupal::service('facetapi.core_manager');
$search_id = 'core_search:' . $search_page->id();
// Sets search keys and adds active filters.
$facet_manager->setSearchKeys($request->query->get('keys'));
// Add the active filters.
$facet_manager->setFacetSourceId($search_id);
$facet_manager->alterQuery($query);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment