diff vendor/chi-teck/drupal-code-generator/templates/d8/hook/search_preprocess.twig @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/chi-teck/drupal-code-generator/templates/d8/hook/search_preprocess.twig	Thu Jul 05 14:24:15 2018 +0000
@@ -0,0 +1,20 @@
+/**
+ * Implements hook_search_preprocess().
+ */
+function {{ machine_name }}_search_preprocess($text, $langcode = NULL) {
+  // If the language is not set, get it from the language manager.
+  if (!isset($langcode)) {
+    $langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
+  }
+
+  // If the langcode is set to 'en' then add variations of the word "testing"
+  // which can also be found during English language searches.
+  if ($langcode == 'en') {
+    // Add the alternate verb forms for the word "testing".
+    if ($text == 'we are testing') {
+      $text .= ' test tested';
+    }
+  }
+
+  return $text;
+}