You are here

public function Index::addDatasource in Search API 8

Adds a datasource to this index.

An existing datasource with the same ID will be replaced.

Parameters

\Drupal\search_api\Datasource\DatasourceInterface $datasource: The datasource to be added.

Return value

$this

Overrides IndexInterface::addDatasource

File

src/Entity/Index.php, line 378

Class

Index
Defines the search index configuration entity.

Namespace

Drupal\search_api\Entity

Code

public function addDatasource(DatasourceInterface $datasource) {

  // Make sure the datasourceInstances are loaded before trying to add a plugin
  // to them.
  if ($this->datasourceInstances === NULL) {
    $this
      ->getDatasources();
  }
  $this->datasourceInstances[$datasource
    ->getPluginId()] = $datasource;
  return $this;
}