public function TaskManager::executeSingleTask in Search API 8
Retrieves and executes a single task.
Parameters
array $conditions: (optional) An array of conditions to be matched for the task, with property names mapped to the value (or values, for multiple possibilities) that the property should have.
Return value
bool TRUE if a task was successfully executed, FALSE if there was no matching task.
Throws
\Drupal\search_api\SearchApiException Thrown if any error occurred while processing the task.
Overrides TaskManagerInterface::executeSingleTask
File
- src/
Task/ TaskManager.php, line 227
Class
- TaskManager
- Provides a service for managing pending tasks.
Namespace
Drupal\search_api\TaskCode
public function executeSingleTask(array $conditions = []) {
$task_id = $this
->getTasksQuery($conditions)
->range(0, 1)
->execute();
if ($task_id) {
$task_id = reset($task_id);
/** @var \Drupal\search_api\Task\TaskInterface $task */
$task = $this
->getTaskStorage()
->load($task_id);
$this
->executeSpecificTask($task);
return TRUE;
}
return FALSE;
}