summaryrefslogtreecommitdiffstats
path: root/core/modules/search/tests/modules/search_langcode_test/search_langcode_test.module
blob: c7d96245df128128319e400d7d8f01f8a961e480 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php

/**
 * @file
 * Test module setting up two tests, one for checking if the entity $langcode is
 * being passed on and another one sets up the alternate verb forms for the
 * stemming test.
 */

/**
 * Implements hook_search_preprocess().
 */
function search_langcode_test_search_preprocess($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';
    }
    // Prints the langcode for testPreprocessLangcode() and adds some
    // extra text.
    else {
      drupal_set_message('Langcode Preprocess Test: ' . $langcode);
      $text .= 'Additional text';
    }
  }
  // Prints the langcode for testPreprocessLangcode().
  elseif (isset($langcode)) {
    drupal_set_message('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;
}