You are here

public function ServerTaskManager::delete in Search API 8

Removes pending server tasks from the list.

Parameters

\Drupal\search_api\ServerInterface|null $server: (optional) A server for which the tasks should be deleted. Set to NULL to delete tasks from all servers.

\Drupal\search_api\IndexInterface|string|null $index: (optional) An index (or its ID) for which the tasks should be deleted. Set to NULL to delete tasks for all indexes.

string[]|null $types: (optional) The types of tasks that should be deleted, or NULL to delete tasks regardless of type.

Overrides ServerTaskManagerInterface::delete

File

src/Task/ServerTaskManager.php, line 192

Class

ServerTaskManager
Provides a service for managing pending server tasks.

Namespace

Drupal\search_api\Task

Code

public function delete(ServerInterface $server = NULL, $index = NULL, array $types = NULL) {
  $conditions = $this
    ->getTaskConditions($server);
  if ($index !== NULL) {
    $conditions['index_id'] = $index instanceof IndexInterface ? $index
      ->id() : $index;
  }
  if ($types !== NULL) {
    $conditions['type'] = $types;
  }
  $this->taskManager
    ->deleteTasks($conditions);
}