You are here

function _search_api_batch_indexing_finished in Search API 7

Batch API finishing callback for the indexing functionality.

Parameters

boolean $success: Whether the batch finished successfully.

array $results: Detailed information about the result.

1 string reference to '_search_api_batch_indexing_finished'
_search_api_batch_indexing_create in ./search_api.module
Creates and sets a batch for indexing items.

File

./search_api.module, line 3466
Provides a flexible framework for implementing search services.

Code

function _search_api_batch_indexing_finished($success, $results) {

  // Check if called from drush.
  if (!empty($results['drush'])) {
    $drupal_set_message = 'drush_log';
    $format_plural = '_search_api_drush_format_plural';
    $t = 'dt';
    $success_message = 'success';
  }
  else {
    $drupal_set_message = 'drupal_set_message';
    $format_plural = 'format_plural';
    $t = 't';
    $success_message = 'status';
  }

  // Display result messages.
  if ($success) {
    if (!empty($results['indexed'])) {
      $drupal_set_message($format_plural($results['indexed'], 'Successfully indexed 1 item.', 'Successfully indexed @count items.'), $success_message);
      if (!empty($results['not indexed'])) {
        $drupal_set_message($format_plural($results['not indexed'], '1 item could not be indexed. Check the logs for details.', '@count items could not be indexed. Check the logs for details.'), 'warning');
      }
    }
    else {
      $drupal_set_message($t("Couldn't index items. Check the logs for details."), 'error');
    }
  }
  else {
    $drupal_set_message($t("An error occurred while trying to index items. Check the logs for details."), 'error');
  }
}