protected function Tokenizer::processFieldValue in Search API 8
Processes a single text element in a field.
The default implementation just calls process().
Parameters
string $value: The string value to preprocess, as a reference. Can be manipulated directly, nothing has to be returned. Can either be left a string, or changed into an array of \Drupal\search_api\Plugin\search_api\data_type\value\TextTokenInterface objects. Returning anything else will result in undefined behavior.
string $type: The field's data type.
Overrides FieldsProcessorPluginBase::processFieldValue
File
- src/
Plugin/ search_api/ processor/ Tokenizer.php, line 218
Class
- Tokenizer
- Splits text into individual words for searching.
Namespace
Drupal\search_api\Plugin\search_api\processorCode
protected function processFieldValue(&$value, $type) {
$this
->prepare();
$text = $this
->simplifyText($value);
// Split on spaces. The configured (or default) delimiters have been
// replaced by those already in simplifyText().
$arr = explode(' ', $text);
$value = [];
foreach ($arr as $token) {
if (is_numeric($token) || mb_strlen($token) >= $this->configuration['minimum_word_size']) {
$value[] = Utility::createTextToken($token);
}
}
}