Commit 585090bb authored by Teun Beijers's avatar Teun Beijers

fix: a spellcheckresult can return multiple collations, all but the last were ignored before this

parent 7b57f3e2
......@@ -66,7 +66,7 @@ class Solarium_Client_ResponseParser_Select_Component_Spellcheck
$suggestions = array();
$correctlySpelled = null;
$collation = null;
$collations = array();
$index = 0;
while (isset($spellcheckResults[$index]) && isset($spellcheckResults[$index+1])) {
......@@ -78,7 +78,7 @@ class Solarium_Client_ResponseParser_Select_Component_Spellcheck
$correctlySpelled = $value;
break;
case 'collation':
$collation = $this->_parseCollation($value);
$collations[] = $this->_parseCollation($value);
break;
default:
$suggestions[] = $this->_parseSuggestion($key, $value);
......@@ -87,7 +87,7 @@ class Solarium_Client_ResponseParser_Select_Component_Spellcheck
$index +=2;
}
return new Solarium_Result_Select_Spellcheck($suggestions, $collation, $correctlySpelled);
return new Solarium_Result_Select_Spellcheck($suggestions, $collations, $correctlySpelled);
} else {
return null;
}
......
......@@ -53,11 +53,11 @@ class Solarium_Result_Select_Spellcheck implements IteratorAggregate, Countable
protected $_suggestions;
/**
* Collation object
* Collation object array
*
* @var Solarium_Result_Select_Spellcheck_Collation
* @var array
*/
protected $_collation;
protected $_collations;
/**
* Correctly spelled?
......@@ -74,21 +74,42 @@ class Solarium_Result_Select_Spellcheck implements IteratorAggregate, Countable
* @param boolean $correctlySpelled
* @return void
*/
public function __construct($suggestions, $collation, $correctlySpelled)
public function __construct($suggestions, $collations, $correctlySpelled)
{
$this->_suggestions = $suggestions;
$this->_collation = $collation;
$this->_collations = $collations;
$this->_correctlySpelled = $correctlySpelled;
}
/**
* Get the collation result
*
*
* @param int $key
* @return Solarium_Result_Select_Spellcheck_Collation
*/
public function getCollation()
public function getCollation($key = null)
{
$nrOfCollations = count($this->_collations);
if ($nrOfCollations == 0) {
return null;
} else {
if ($key === null) {
$key = $nrOfCollations - 1; // for backwards compatibility
}
return $this->_collations[$key];
}
}
/**
* Get all collations
*
* @return array
*/
public function getCollations()
{
return $this->_collation;
return $this->_collations;
}
/**
......
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