public function Server::updateIndex in Search API 8
Notifies the server that an index attached to it has been changed.
If any user action is necessary as a result of this, the method should set a message to notify the user.
Parameters
\Drupal\search_api\IndexInterface $index: The updated index.
Throws
\Drupal\search_api\SearchApiException Thrown if an error occurred while reacting to the change.
Overrides BackendSpecificInterface::updateIndex
File
- src/
Entity/ Server.php, line 290
Class
- Server
- Defines the search server configuration entity.
Namespace
Drupal\search_api\EntityCode
public function updateIndex(IndexInterface $index) {
$server_task_manager = \Drupal::getContainer()
->get('search_api.server_task_manager');
try {
if ($server_task_manager
->execute($this)) {
$this
->getBackend()
->updateIndex($index);
return;
}
} catch (SearchApiException $e) {
$vars = [
'%server' => $this
->label(),
'%index' => $index
->label(),
];
$this
->logException($e, '%type while updating the fields of index %index on server %server: @message in %function (line %line of %file).', $vars);
}
$task_manager = \Drupal::getContainer()
->get('search_api.task_manager');
$task_manager
->addTask(__FUNCTION__, $this, $index, $index->original ?? NULL);
}