annotate vendor/chi-teck/drupal-code-generator/templates/d8/hook/search_preprocess.twig @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents c75dbcec494b
children
rev   line source
Chris@0 1 /**
Chris@0 2 * Implements hook_search_preprocess().
Chris@0 3 */
Chris@0 4 function {{ machine_name }}_search_preprocess($text, $langcode = NULL) {
Chris@0 5 // If the language is not set, get it from the language manager.
Chris@0 6 if (!isset($langcode)) {
Chris@0 7 $langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
Chris@0 8 }
Chris@0 9
Chris@0 10 // If the langcode is set to 'en' then add variations of the word "testing"
Chris@0 11 // which can also be found during English language searches.
Chris@0 12 if ($langcode == 'en') {
Chris@0 13 // Add the alternate verb forms for the word "testing".
Chris@0 14 if ($text == 'we are testing') {
Chris@0 15 $text .= ' test tested';
Chris@0 16 }
Chris@0 17 }
Chris@0 18
Chris@0 19 return $text;
Chris@0 20 }