Add event subscriber.
This commit is contained in:
parent
15703a124b
commit
6123df49a2
2 changed files with 35 additions and 0 deletions
4
advanced_search.services.yml
Normal file
4
advanced_search.services.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
services:
|
||||||
|
Drupal\advanced_search\EventSubscriber\PostConvertedQueryEventSubscriber:
|
||||||
|
tags:
|
||||||
|
- { name: 'event_subscriber' }
|
||||||
31
src/EventSubscriber/PostConvertedQueryEventSubscriber.php
Normal file
31
src/EventSubscriber/PostConvertedQueryEventSubscriber.php
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\advanced_search\EventSubscriber;
|
||||||
|
|
||||||
|
use Drupal\advanced_search\AdvancedSearchQuery;
|
||||||
|
use Drupal\search_api_solr\Event\SearchAPISolrEvents;
|
||||||
|
use Drupal\search_api_solr\Event\PostConvertedQueryEvent;
|
||||||
|
|
||||||
|
class PostConvertedQueryEventSubscriber extends EventSubscriberInterface() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public static function getSubscribedEvents() {
|
||||||
|
$events[SearchAPISolrEvents::POST_CONVERT_QUERY][] = ['alter'];
|
||||||
|
|
||||||
|
return $events;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alter the query.
|
||||||
|
*/
|
||||||
|
public function alter(PostConvertedQueryEvent $event) {
|
||||||
|
$search_api_query = $event->getSearchApiQuery();
|
||||||
|
$solarium_query = $event->getSolariumQuery();
|
||||||
|
$advanced_search_query = new AdvancedSearchQuery();
|
||||||
|
$advanced_search_query->alterQuery(\Drupal::request(), $solarium_query, $search_api_query);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue