You are here

interface TaskManagerInterface in Search API 8

Defines the interface of the Search API task manager service.

Hierarchy

Expanded class hierarchy of TaskManagerInterface

All classes that implement TaskManagerInterface

4 files declare their use of TaskManagerInterface
ContentEntityTaskManager.php in src/Plugin/search_api/datasource/ContentEntityTaskManager.php
ContentEntityTrackingManager.php in src/Plugin/search_api/datasource/ContentEntityTrackingManager.php
TaskController.php in src/Controller/TaskController.php
TestTaskWorker.php in tests/search_api_test_tasks/src/TestTaskWorker.php

File

src/Task/TaskManagerInterface.php, line 11

Namespace

Drupal\search_api\Task
View source
interface TaskManagerInterface {

  /**
   * Retrieves the number of pending tasks for the given conditions.
   *
   * @param array $conditions
   *   (optional) An array of conditions to be matched for the tasks, with
   *   property names mapped to the value (or values, for multiple
   *   possibilities) that the property should have.
   *
   * @return int
   *   The number of pending tasks matching the conditions.
   */
  public function getTasksCount(array $conditions = []);

  /**
   * Adds a new pending task.
   *
   * In case this would duplicate an existing task, that existing task is
   * returned instead.
   *
   * @param string $type
   *   The type of task.
   * @param \Drupal\search_api\ServerInterface|null $server
   *   (optional) The search server associated with the task, if any.
   * @param \Drupal\search_api\IndexInterface|null $index
   *   (optional) The search index associated with the task, if any.
   * @param mixed|null $data
   *   (optional) Additional, type-specific data to save with the task.
   *
   * @return \Drupal\search_api\Task\TaskInterface
   *   The new task, or an identical existing task.
   */
  public function addTask($type, ServerInterface $server = NULL, IndexInterface $index = NULL, $data = NULL);

  /**
   * Load all tasks matching the given conditions.
   *
   * @param array $conditions
   *   (optional) An array of conditions to be matched for the tasks, with
   *   property names mapped to the value (or values, for multiple
   *   possibilities) that the property should have.
   *
   * @return \Drupal\search_api\Task\TaskInterface[]
   *   The loaded tasks, keyed by task ID.
   */
  public function loadTasks(array $conditions = []);

  /**
   * Deletes the task with the given ID.
   *
   * @param int $task_id
   *   The task's ID.
   */
  public function deleteTask($task_id);

  /**
   * Deletes all tasks that fulfil a certain set of conditions.
   *
   * @param array $conditions
   *   (optional) An array of conditions defining which tasks should be deleted.
   *   The structure is an associative array with property names mapped to the
   *   value (or values, for multiple possibilities) that the property should
   *   have. Leave empty to delete all pending tasks.
   */
  public function deleteTasks(array $conditions = []);

  /**
   * Executes and deletes the given task.
   *
   * @param \Drupal\search_api\Task\TaskInterface $task
   *   The task to execute.
   *
   * @throws \Drupal\search_api\SearchApiException
   *   Thrown if any error occurred while processing the task.
   */
  public function executeSpecificTask(TaskInterface $task);

  /**
   * Retrieves and executes a single task.
   *
   * @param 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 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.
   */
  public function executeSingleTask(array $conditions = []);

  /**
   * Executes all (or some) pending tasks.
   *
   * @param array $conditions
   *   (optional) An array of conditions to be matched for the tasks, with
   *   property names mapped to the value (or values, for multiple
   *   possibilities) that the property should have.
   * @param int|null $limit
   *   (optional) If given, only this number of tasks will be executed.
   *
   * @return bool
   *   TRUE if all tasks matching the conditions have been executed, FALSE if
   *   $limit was given and lower than the total count of pending tasks matching
   *   the conditions.
   *
   * @throws \Drupal\search_api\SearchApiException
   *   Thrown if any error occurred while processing a task.
   */
  public function executeAllTasks(array $conditions = [], $limit = NULL);

  /**
   * Sets a batch for executing all pending tasks.
   *
   * @param array $conditions
   *   (optional) An array of conditions to be matched for the tasks, with
   *   property names mapped to the value (or values, for multiple
   *   possibilities) that the property should have.
   */
  public function setTasksBatch(array $conditions = []);

}

Members

Namesort descending Modifiers Type Description Overrides
TaskManagerInterface::addTask public function Adds a new pending task. 1
TaskManagerInterface::deleteTask public function Deletes the task with the given ID. 1
TaskManagerInterface::deleteTasks public function Deletes all tasks that fulfil a certain set of conditions. 1
TaskManagerInterface::executeAllTasks public function Executes all (or some) pending tasks. 1
TaskManagerInterface::executeSingleTask public function Retrieves and executes a single task. 1
TaskManagerInterface::executeSpecificTask public function Executes and deletes the given task. 1
TaskManagerInterface::getTasksCount public function Retrieves the number of pending tasks for the given conditions. 1
TaskManagerInterface::loadTasks public function Load all tasks matching the given conditions. 1
TaskManagerInterface::setTasksBatch public function Sets a batch for executing all pending tasks. 1