protected function ServerTaskManager::executeTask in Search API 8
Executes a single server task.
Parameters
\Drupal\search_api\Task\TaskInterface $task: The task to execute.
Return value
bool TRUE if the task was successfully executed, FALSE if the task type was unknown.
Throws
\Drupal\search_api\SearchApiException If any error occurred while executing the task.
1 call to ServerTaskManager::executeTask()
- ServerTaskManager::processEvent in src/
Task/ ServerTaskManager.php - Processes a single server task.
File
- src/
Task/ ServerTaskManager.php, line 137
Class
- ServerTaskManager
- Provides a service for managing pending server tasks.
Namespace
Drupal\search_api\TaskCode
protected function executeTask(TaskInterface $task) {
$server = $task
->getServer();
$index = $task
->getIndex();
$data = $task
->getData();
switch ($task
->getType()) {
case 'addIndex':
if ($index) {
$server
->getBackend()
->addIndex($index);
}
return TRUE;
case 'updateIndex':
if ($index) {
if ($data) {
$index->original = $data;
}
$server
->getBackend()
->updateIndex($index);
}
return TRUE;
case 'removeIndex':
$index = $index ?: $data;
if ($index) {
$server
->getBackend()
->removeIndex($index);
}
return TRUE;
case 'deleteItems':
if ($index && !$index
->isReadOnly()) {
$server
->getBackend()
->deleteItems($index, $data);
}
return TRUE;
case 'deleteAllIndexItems':
if ($index && !$index
->isReadOnly()) {
$server
->getBackend()
->deleteAllIndexItems($index, $data);
}
return TRUE;
}
// We didn't know that type of task.
return FALSE;
}