Commit 1707d4b5 authored by Bas de Nooijer's avatar Bas de Nooijer

Merge pull request #88 from teuneboon/master

Fixed collations to be able to use multiple collations
parents 944bf5c7 585090bb
...@@ -66,7 +66,7 @@ class Solarium_Client_ResponseParser_Select_Component_Spellcheck ...@@ -66,7 +66,7 @@ class Solarium_Client_ResponseParser_Select_Component_Spellcheck
$suggestions = array(); $suggestions = array();
$correctlySpelled = null; $correctlySpelled = null;
$collation = null; $collations = array();
$index = 0; $index = 0;
while (isset($spellcheckResults[$index]) && isset($spellcheckResults[$index+1])) { while (isset($spellcheckResults[$index]) && isset($spellcheckResults[$index+1])) {
...@@ -78,7 +78,7 @@ class Solarium_Client_ResponseParser_Select_Component_Spellcheck ...@@ -78,7 +78,7 @@ class Solarium_Client_ResponseParser_Select_Component_Spellcheck
$correctlySpelled = $value; $correctlySpelled = $value;
break; break;
case 'collation': case 'collation':
$collation = $this->_parseCollation($value); $collations[] = $this->_parseCollation($value);
break; break;
default: default:
$suggestions[] = $this->_parseSuggestion($key, $value); $suggestions[] = $this->_parseSuggestion($key, $value);
...@@ -87,7 +87,7 @@ class Solarium_Client_ResponseParser_Select_Component_Spellcheck ...@@ -87,7 +87,7 @@ class Solarium_Client_ResponseParser_Select_Component_Spellcheck
$index +=2; $index +=2;
} }
return new Solarium_Result_Select_Spellcheck($suggestions, $collation, $correctlySpelled); return new Solarium_Result_Select_Spellcheck($suggestions, $collations, $correctlySpelled);
} else { } else {
return null; return null;
} }
......
...@@ -53,11 +53,11 @@ class Solarium_Result_Select_Spellcheck implements IteratorAggregate, Countable ...@@ -53,11 +53,11 @@ class Solarium_Result_Select_Spellcheck implements IteratorAggregate, Countable
protected $_suggestions; protected $_suggestions;
/** /**
* Collation object * Collation object array
* *
* @var Solarium_Result_Select_Spellcheck_Collation * @var array
*/ */
protected $_collation; protected $_collations;
/** /**
* Correctly spelled? * Correctly spelled?
...@@ -74,21 +74,42 @@ class Solarium_Result_Select_Spellcheck implements IteratorAggregate, Countable ...@@ -74,21 +74,42 @@ class Solarium_Result_Select_Spellcheck implements IteratorAggregate, Countable
* @param boolean $correctlySpelled * @param boolean $correctlySpelled
* @return void * @return void
*/ */
public function __construct($suggestions, $collation, $correctlySpelled) public function __construct($suggestions, $collations, $correctlySpelled)
{ {
$this->_suggestions = $suggestions; $this->_suggestions = $suggestions;
$this->_collation = $collation; $this->_collations = $collations;
$this->_correctlySpelled = $correctlySpelled; $this->_correctlySpelled = $correctlySpelled;
} }
/** /**
* Get the collation result * Get the collation result
* *
* @param int $key
* @return Solarium_Result_Select_Spellcheck_Collation * @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