materio-base-legacy/includes/spellcheck.inc
Bachir Soussi Chiadmi d8237ffb99 updated to 1.2
2013-09-26 16:23:17 +02:00

34 lines
896 B
PHP

<?php
/**
* @file
* Contains the SearchApiSpellcheckSolr class.
*/
/**
* Spellcheck class which can provide spelling suggestions. The constructor
* populates the instance with any suggestions returned by Solr.
*/
class SearchApiSpellcheckSolr extends SearchApiSpellcheck {
/**
* Constructs a SearchApiSpellcheckSolr object.
*
* If Solr has returned spelling suggestion then loop through them and add
* them to this spellcheck service.
*
* @param object $response
* The Solr response object.
*/
function __construct($response) {
if (isset($response->spellcheck->suggestions)) {
$suggestions = $response->spellcheck->suggestions;
foreach ($suggestions as $word => $data) {
foreach ($data->suggestion as $suggestion) {
$this->addSuggestion(new SearchApiSpellcheckSuggestion($word, $suggestion));
}
}
}
}
}