You are here

public static function SearchApiAlgoliaCommands::batchFinish in Search API Algolia 3.0.x

Finishes the update process and prints the results.

Parameters

bool $success: Indicate that the batch API tasks were all completed successfully.

array $results: An array of all the results that were updated.

array $operations: A list of all the operations that had not been completed by batch API.

File

src/Commands/SearchApiAlgoliaCommands.php, line 176

Class

SearchApiAlgoliaCommands
Class Search Api Algolia commands.

Namespace

Drupal\search_api_algolia\Commands

Code

public static function batchFinish($success, array $results, array $operations) {
  $logger = \Drupal::logger('search_api_algolia');
  if ($success) {
    if ($results['count']) {

      // Display Script execution time.
      $time_end = microtime(TRUE);
      $execution_time = ($time_end - $results['timestart']) / 60;
      $logger
        ->notice('Total @count items processed in time: @time.', [
        '@count' => $results['count'],
        '@time' => $execution_time,
      ]);
    }
    else {
      $logger
        ->notice('No items processed.');
    }
  }
  else {
    $error_operation = reset($operations);
    $logger
      ->error('An error occurred while processing @operation with arguments : @args', [
      '@operation' => $error_operation[0],
      '@args' => print_r($error_operation[0], TRUE),
    ]);
  }
}