public function Index::getServerInstance in Search API 8
Retrieves the server the index is attached to.
Return value
\Drupal\search_api\ServerInterface|null The server this index is linked to, or NULL if the index doesn't have a server.
Throws
\Drupal\search_api\SearchApiException Thrown if the server couldn't be loaded.
Overrides IndexInterface::getServerInstance
1 call to Index::getServerInstance()
- Index::reactToDatasourceSwitch in src/
Entity/ Index.php - Checks whether the index's datasources changed and reacts accordingly.
File
- src/
Entity/ Index.php, line 500
Class
- Index
- Defines the search index configuration entity.
Namespace
Drupal\search_api\EntityCode
public function getServerInstance() {
if (!$this->serverInstance && $this->server) {
$this->serverInstance = Server::load($this->server);
if (!$this->serverInstance) {
$index_label = $this
->label();
throw new SearchApiException("The server with ID '{$this->server}' could not be retrieved for index '{$index_label}'.");
}
}
return $this->serverInstance;
}