You are here

public static function Utility::hasIndexJustSolrDatasources in Search API Solr 4.x

Same name and namespace in other branches
  1. 8.3 src/Utility/Utility.php \Drupal\search_api_solr\Utility\Utility::hasIndexJustSolrDatasources()

Returns whether the index only contains "solr_*" datasources.

Parameters

\Drupal\search_api\IndexInterface $index: The Search API index entity.

Return value

bool TRUE if the index only contains "solr_*" datasources, FALSE otherwise.

4 calls to Utility::hasIndexJustSolrDatasources()
SearchApiSolrBackend::extractResults in src/Plugin/search_api/backend/SearchApiSolrBackend.php
Extract results from a Solr response.
SearchApiSolrBackend::formatSolrFieldNames in src/Plugin/search_api/backend/SearchApiSolrBackend.php
Returns a language-specific mapping from Drupal to Solr field names.
SearchApiSolrBackend::getMoreLikeThisQuery in src/Plugin/search_api/backend/SearchApiSolrBackend.php
Changes the query to a "More Like This" query.
SearchApiSolrBackend::hasIndexJustSolrDatasources in src/Plugin/search_api/backend/SearchApiSolrBackend.php
Returns whether the index only contains "solr_*" datasources.

File

src/Utility/Utility.php, line 980

Class

Utility
Provides various helper functions for Solr backends.

Namespace

Drupal\search_api_solr\Utility

Code

public static function hasIndexJustSolrDatasources(IndexInterface $index) : bool {
  static $datasources = [];
  if (!isset($datasources[$index
    ->id()])) {
    $datasource_ids = $index
      ->getDatasourceIds();
    $datasource_ids = array_filter($datasource_ids, function ($datasource_id) {
      return strpos($datasource_id, 'solr_') !== 0;
    });
    $datasources[$index
      ->id()] = !$datasource_ids;
  }
  return $datasources[$index
    ->id()];
}