You are here

function search_api_entity_extra_field_info in Search API 8

Implements hook_entity_extra_field_info().

File

./search_api.module, line 621
Provides a rich framework for creating searches.

Code

function search_api_entity_extra_field_info() {
  $extra = [];

  // Add an extra "excerpt" field to every content entity.
  $entity_types = \Drupal::entityTypeManager()
    ->getDefinitions();
  $bundle_info = \Drupal::getContainer()
    ->get('entity_type.bundle.info');
  foreach ($entity_types as $entity_type_id => $entity_type) {
    if ($entity_type instanceof ContentEntityType) {
      $bundles = $bundle_info
        ->getBundleInfo($entity_type_id);
      foreach ($bundles as $bundle => $data) {
        $extra[$entity_type_id][$bundle]['display']['search_api_excerpt'] = [
          'label' => t('Search result excerpt'),
          'description' => t('An excerpt provided by Search API when rendered in a search.'),
          'weight' => 100,
          'visible' => FALSE,
        ];
      }
    }
  }
  return $extra;
}