protected function Database::eliminateDuplicates in Search API 8
Eliminates duplicate keys from a keyword array.
Used as a helper method in prepareKeys().
Parameters
array $keys: The keywords to parse.
array $words: (optional) A cache of all encountered words so far. Used internally for recursive invocations.
Return value
array The processed keywords.
1 call to Database::eliminateDuplicates()
- Database::prepareKeys in modules/
search_api_db/ src/ Plugin/ search_api/ backend/ Database.php - Removes nested expressions and phrase groupings from the search keys.
File
- modules/
search_api_db/ src/ Plugin/ search_api/ backend/ Database.php, line 1921
Class
- Database
- Indexes and searches items using the database.
Namespace
Drupal\search_api_db\Plugin\search_api\backendCode
protected function eliminateDuplicates(array $keys, array &$words = []) {
foreach ($keys as $i => $word) {
if (!Element::child($i)) {
continue;
}
if (is_scalar($word)) {
if (isset($words[$word])) {
unset($keys[$i]);
}
else {
$words[$word] = TRUE;
}
}
else {
$keys[$i] = $this
->eliminateDuplicates($word, $words);
}
}
return $keys;
}