public static function SuggestionHelper::atomize in Autocomplete Search Suggestions 8
Same name and namespace in other branches
- 8.2 src/SuggestionHelper.php \Drupal\suggestion\SuggestionHelper::atomize()
- 3.0.x src/SuggestionHelper.php \Drupal\suggestion\SuggestionHelper::atomize()
Transform a string to an array.
Parameters
string $txt: The string to process.
Return value
array An array of atoms.
2 calls to SuggestionHelper::atomize()
- SuggestionHelper::insert in src/
SuggestionHelper.php - Add a suggestion.
- suggestion_surfer_submit in ./
suggestion.module - Custom submit function to add surfer suggestions.
File
- src/
SuggestionHelper.php, line 64
Class
- SuggestionHelper
- Provides helper methods for suggestions.
Namespace
Drupal\suggestionCode
public static function atomize($txt = '') {
$atoms = [];
$stopwords = self::getStops('stopwords');
foreach (preg_split('/\\s+/', $txt) as $atom) {
if (!empty($stopwords[$atom])) {
continue;
}
$atoms[$atom] = $atom;
}
return $atoms;
}