You are here

public static function Importer::createSynonymBatchFinishedCallback in Search API Synonym 8

Batch finished callback.

Parameters

bool $success: Was the batch successful or not?

array $result: Array with the result of the import.

array $operations: Batch operations.

string $elapsed: Formatted string with the time batch operation was running.

File

src/Import/Importer.php, line 238

Class

Importer
Importer class.

Namespace

Drupal\search_api_synonym\Import

Code

public static function createSynonymBatchFinishedCallback($success, $result, $operations, $elapsed) {
  if ($success) {

    // Set message before returning to form.
    if (!empty($result['success'])) {
      $count = count($result['success']);
      $message = \Drupal::translation()
        ->formatPlural($count, '@count synonym was successfully imported.', '@count synonyms was successfully imported.', [
        '@count' => $count,
      ]);
      \Drupal::service('messenger')
        ->addMessage($message);
    }
  }
}