public static function SuggestionHelper::updateSrc in Autocomplete Search Suggestions 8.2
Same name and namespace in other branches
- 8 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.
string $langcode: The language code.
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 388
Class
- SuggestionHelper
- Provides helper methods for suggestions.
Namespace
Drupal\suggestionCode
public static function updateSrc($ngram = '', $src = 0, $langcode = '') {
$obj = SuggestionStorage::getSuggestion($ngram);
$key = [
'langcode' => $langcode,
'ngram' => $ngram,
];
$fields = [
'atoms' => $obj->atoms,
'density' => self::calculateDensity($src, $obj->atoms, $obj->qty),
'qty' => $obj->qty,
'src' => $src,
];
return SuggestionStorage::mergeSuggestion($key, $fields);
}