class SearchApiSubscriber in Search API Solr 4.x
Search API events subscriber.
Hierarchy
- class \Drupal\search_api_solr\EventSubscriber\SearchApiSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of SearchApiSubscriber
1 string reference to 'SearchApiSubscriber'
1 service uses SearchApiSubscriber
File
- src/
EventSubscriber/ SearchApiSubscriber.php, line 11
Namespace
Drupal\search_api_solr\EventSubscriberView source
class SearchApiSubscriber implements EventSubscriberInterface {
/**
* Adds the mapping to treat some Solr special fields as fulltext in views.
*
* @param \Drupal\search_api\Event\MappingViewsFieldHandlersEvent $event
* The Search API event.
*/
public function onMappingViewsFieldHandlers($event) {
$mapping =& $event
->getFieldHandlerMapping();
$mapping['solr_text_omit_norms'] = $mapping['solr_text_suggester'] = $mapping['solr_text_unstemmed'] = $mapping['solr_text_wstoken'] = [
'argument' => [
'id' => 'search_api',
],
'filter' => [
'id' => 'search_api_fulltext',
],
'sort' => [
'id' => 'search_api',
],
];
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
// Workaround to avoid a fatal error during site install in some cases.
// @see https://www.drupal.org/project/facets/issues/3199156
if (!class_exists('\\Drupal\\search_api\\Event\\SearchApiEvents', TRUE)) {
return [];
}
return [
SearchApiEvents::MAPPING_VIEWS_FIELD_HANDLERS => 'onMappingViewsFieldHandlers',
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SearchApiSubscriber:: |
public static | function | ||
SearchApiSubscriber:: |
public | function | Adds the mapping to treat some Solr special fields as fulltext in views. |