You are here

function search_api_views_plugins_cache_alter in Search API 8

Implements hook_views_plugins_cache_alter().

File

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

Code

function search_api_views_plugins_cache_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_tag']['base'] = $bases;
  $plugins['search_api_time']['base'] = $bases;
}