You are here

function search_api_views_plugins_row_alter in Search API 8

Implements hook_views_plugins_row_alter().

File

./search_api.views.inc, line 147
Views hook implementations for the Search API module.

Code

function search_api_views_plugins_row_alter(array &$plugins) {

  // Collect all base tables provided by this module.
  $bases = [];

  /** @var \Drupal\search_api\IndexInterface $index */
  foreach (Index::loadMultiple() as $index) {
    $bases[] = 'search_api_index_' . $index
      ->id();
  }

  // If no search indexes are defined yet, declare a dummy index as the base
  // table. This will make sure our plugins do not become available for Views
  // that are not based on search indexes.
  if (!$bases) {
    $bases = [
      'search_api_index_dummy',
    ];
  }
  $plugins['search_api']['base'] = $bases;
  $plugins['search_api_data']['base'] = $bases;
}