You are here

public function Item::__construct in Search API 8

Constructs an Item object.

Parameters

\Drupal\search_api\IndexInterface $index: The item's search index.

string $id: The ID of this item.

\Drupal\search_api\Datasource\DatasourceInterface|null $datasource: (optional) The datasource of this item. If not set, it will be determined from the ID and loaded from the index.

File

src/Item/Item.php, line 137

Class

Item
Provides a default implementation for a search item.

Namespace

Drupal\search_api\Item

Code

public function __construct(IndexInterface $index, $id, DatasourceInterface $datasource = NULL) {
  $this->index = $index;
  $this->itemId = $id;
  if ($datasource) {
    $this->datasource = $datasource;
    $this->datasourceId = $datasource
      ->getPluginId();
  }
}