You are here

public static function SuggestionHelper::atomize in Autocomplete Search Suggestions 3.0.x

Same name and namespace in other branches
  1. 8.2 src/SuggestionHelper.php \Drupal\suggestion\SuggestionHelper::atomize()
  2. 8 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\suggestion

Code

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;
}