function _search_index_truncate

_search_index_truncate(&$text)

Helper function for array_walk in search_index_split.

File

core/modules/search/search.module, line 382
Enables site-wide keyword searching.

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 = array();
  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;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!search!search.module/function/_search_index_truncate/8.1.x