search_api-8.x-1.15/tests/search_api_test_excerpt_field/search_api_test_excerpt_field.module

tests/search_api_test_excerpt_field/search_api_test_excerpt_field.module
<?php

/**
 * @file
 * Contains hook implementations for the Search API Excerpt Field Test module.
 */

use Drupal\search_api\Query\ResultSetInterface;

/**
 * Implements hook_search_api_results_alter().
 */
function search_api_test_excerpt_field_search_api_results_alter(ResultSetInterface &$results) {
  $excerptTemplate = 'Item {{item_id}} test excerpt';
  $excerptTemplate = \Drupal::state()
    ->get('search_api_test_excerpt_field', $excerptTemplate);
  foreach ($results->getResultItems() as $itemId => $item) {
    $item->setExcerpt(str_replace('{{item_id}}', $itemId, $excerptTemplate));
  }
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc