You are here

public function IndexTaskManager::startTracking in Search API 8

Creates a task to start tracking for the given index, or some datasources.

Parameters

\Drupal\search_api\IndexInterface $index: The search index.

string[]|null $datasource_ids: (optional) The IDs of specific datasources for which tracking should start. Or NULL to start tracking for all datasources.

Overrides IndexTaskManagerInterface::startTracking

File

src/Task/IndexTaskManager.php, line 168

Class

IndexTaskManager
Provides a service for managing pending index tasks.

Namespace

Drupal\search_api\Task

Code

public function startTracking(IndexInterface $index, array $datasource_ids = NULL) {
  foreach ($datasource_ids ?? $index
    ->getDatasourceIds() as $datasource_id) {
    $data = [
      'datasource' => $datasource_id,
      'page' => 0,
    ];
    $this->taskManager
      ->addTask(self::TRACK_ITEMS_TASK_TYPE, NULL, $index, $data);
  }
}