You are here

public function ServerTaskManager::execute in Search API 8

Checks for pending tasks on one or all enabled search servers.

Parameters

\Drupal\search_api\ServerInterface|null $server: (optional) The server whose tasks should be executed. If not given, the tasks for all enabled servers are executed.

Return value

bool TRUE if all tasks (for the specific server, if $server was given) were executed successfully, or if there were no tasks. FALSE if there are still pending tasks.

Overrides ServerTaskManagerInterface::execute

File

src/Task/ServerTaskManager.php, line 87

Class

ServerTaskManager
Provides a service for managing pending server tasks.

Namespace

Drupal\search_api\Task

Code

public function execute(ServerInterface $server = NULL) {
  if ($server && !$server
    ->status()) {
    return FALSE;
  }
  $conditions = $this
    ->getTaskConditions($server);
  try {
    return $this->taskManager
      ->executeAllTasks($conditions, 100);
  } catch (SearchApiException $e) {
    $this
      ->logException($e);
    return FALSE;
  }
}