You are here

public function Index::getDatasource in Search API 8

Retrieves a specific datasource plugin for this index.

Parameters

string $datasource_id: The ID of the datasource plugin to return.

Return value

\Drupal\search_api\Datasource\DatasourceInterface The datasource plugin with the given ID.

Throws

\Drupal\search_api\SearchApiException Thrown if the specified datasource isn't enabled for this index, or couldn't be loaded.

Overrides IndexInterface::getDatasource

2 calls to Index::getDatasource()
Index::getPropertyDefinitions in src/Entity/Index.php
Retrieves the properties of one of this index's datasources.
Index::loadItemsMultiple in src/Entity/Index.php
Loads multiple search objects for this index.

File

src/Entity/Index.php, line 364

Class

Index
Defines the search index configuration entity.

Namespace

Drupal\search_api\Entity

Code

public function getDatasource($datasource_id) {
  $datasources = $this
    ->getDatasources();
  if (empty($datasources[$datasource_id])) {
    $index_label = $this
      ->label();
    throw new SearchApiException("The datasource with ID '{$datasource_id}' could not be retrieved for index '{$index_label}'.");
  }
  return $datasources[$datasource_id];
}