You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.0 KiB
40 lines
1.0 KiB
<?php |
|
|
|
namespace Drupal\roblib_solr_query_alter\EventSubscriber; |
|
|
|
use Drupal\advanced_search\AdvancedSearchQuery; |
|
use Drupal\search_api_solr\Event\PostConvertedQueryEvent; |
|
use Drupal\search_api_solr\Event\SearchApiSolrEvents; |
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
|
|
|
/** |
|
* Subscribes to PostConvertedQueryEvents. |
|
* |
|
* @package Drupal\advanced_search\EventSubscriber |
|
*/ |
|
class PostConvertedQueryEventSubscriber implements EventSubscriberInterface { |
|
|
|
/** |
|
* {@inheritdoc} |
|
*/ |
|
public static function getSubscribedEvents() { |
|
$events[SearchAPISolrEvents::POST_CONVERT_QUERY][] = ['alterSolariumQuery']; |
|
|
|
return $events; |
|
|
|
} |
|
|
|
/** |
|
* Alter the query. |
|
*/ |
|
public function alterSolariumQuery(PostConvertedQueryEvent $event) { |
|
//$search_api_query = $event->getSearchApiQuery(); |
|
$solarium_query = $event->getSolariumQuery(); |
|
$handler = $solarium_query->getHandler(); |
|
if($handler == 'select') { |
|
$solarium_query->getFilterQuery('index_filter') |
|
->setQuery(''); |
|
} |
|
} |
|
|
|
}
|
|
|