public static function SuggestionHelper::updateSrc in Autocomplete Search Suggestions 8
Same name and namespace in other branches
- 8.2 src/SuggestionHelper.php \Drupal\suggestion\SuggestionHelper::updateSrc()
- 3.0.x src/SuggestionHelper.php \Drupal\suggestion\SuggestionHelper::updateSrc()
Calculate the ngram's density.
Parameters
string $ngram: The ngram to update.
int $src: The ngram source.
Return value
object A Merge object.
1 call to SuggestionHelper::updateSrc()
- SuggestionSearchForm::submitUpdateForm in src/
Form/ SuggestionSearchForm.php - Ngram update submission function.
File
- src/
SuggestionHelper.php, line 356
Class
- SuggestionHelper
- Provides helper methods for suggestions.
Namespace
Drupal\suggestionCode
public static function updateSrc($ngram = '', $src = 0) {
$obj = SuggestionStorage::getSuggestion($ngram);
$key = [
'ngram' => $ngram,
];
$fields = [
'atoms' => $obj->atoms,
'density' => self::calculateDensity($src, $obj->atoms, $obj->qty),
'qty' => $obj->qty,
'src' => $src,
];
return SuggestionStorage::mergeSuggestion($key, $fields);
}