class SearchLangcodeTestHooks
Hook implementations for search_langcode_test.
Hierarchy
- class \Drupal\search_langcode_test\Hook\SearchLangcodeTestHooks
Expanded class hierarchy of SearchLangcodeTestHooks
File
-
core/
modules/ search/ tests/ modules/ search_langcode_test/ src/ Hook/ SearchLangcodeTestHooks.php, line 12
Namespace
Drupal\search_langcode_test\HookView source
class SearchLangcodeTestHooks {
/**
* Implements hook_search_preprocess().
*/
public function searchPreprocess($text, $langcode = NULL) {
if (isset($langcode) && $langcode == 'en') {
// Add the alternate verb forms for the word "testing".
if ($text == 'we are testing') {
$text .= ' test tested';
}
else {
\Drupal::messenger()->addStatus('Langcode Preprocess Test: ' . $langcode);
$text .= 'Additional text';
}
}
elseif (isset($langcode)) {
\Drupal::messenger()->addStatus('Langcode Preprocess Test: ' . $langcode);
// Preprocessing for the excerpt test.
if ($langcode == 'ex') {
$text = str_replace('finding', 'find', $text);
$text = str_replace('finds', 'find', $text);
$text = str_replace('dic', ' dependency injection container', $text);
$text = str_replace('hypertext markup language', 'html', $text);
}
}
return $text;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
SearchLangcodeTestHooks::searchPreprocess | public | function | Implements hook_search_preprocess(). |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.