function _search_index_truncate

Same name in other branches
  1. 7.x modules/search/search.module \_search_index_truncate()

Helper function for array_walk in search_index_split.

1 string reference to '_search_index_truncate'
search_simplify in core/modules/search/search.module
Simplifies and preprocesses text for searching.

File

core/modules/search/search.module, line 350

Code

function _search_index_truncate(&$text) {
    // Use a static array to avoid re-truncating text we've done before.
    // The same words may often be passed in during excerpt generation.
    static $truncated = [];
    if (isset($truncated[$text])) {
        $text = $truncated[$text];
        return;
    }
    // If we didn't find it in the static array, perform the operation.
    $original = $text;
    if (is_numeric($text)) {
        $text = ltrim($text, '0');
    }
    $text = Unicode::truncate($text, 50);
    // Save it for the next time.
    $truncated[$original] = $text;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.