You are here

public function Search::getIndex in Search API Autocomplete 8

Retrieves the index this search belongs to.

Return value

\Drupal\search_api\IndexInterface The index this search belongs to.

Throws

\Drupal\search_api_autocomplete\SearchApiAutocompleteException Thrown if the index couldn't be retrieved.

Overrides SearchInterface::getIndex

File

src/Entity/Search.php, line 209

Class

Search
Describes the autocomplete settings for a certain search.

Namespace

Drupal\search_api_autocomplete\Entity

Code

public function getIndex() {
  if (!isset($this->index)) {
    $this->index = Index::load($this->index_id);
    if (!$this->index) {
      throw new SearchApiAutocompleteException("The index with ID \"{$this->index_id}\" could not be loaded.");
    }
  }
  return $this->index;
}