You are here

function devel_generate_batch_finished in Devel 4.x

Same name and namespace in other branches
  1. 8.3 devel_generate/devel_generate.batch.inc \devel_generate_batch_finished()
  2. 8 devel_generate/devel_generate.batch.inc \devel_generate_batch_finished()
  3. 8.2 devel_generate/devel_generate.batch.inc \devel_generate_batch_finished()
  4. 6 devel_generate_batch.inc \devel_generate_batch_finished()
  5. 7 devel_generate/devel_generate_batch.inc \devel_generate_batch_finished()

Standard finish batch function.

2 string references to 'devel_generate_batch_finished'
ContentDevelGenerate::generateBatchContent in devel_generate/src/Plugin/DevelGenerate/ContentDevelGenerate.php
Generate content in batch mode.
MediaDevelGenerate::generateBatchMedia in devel_generate/src/Plugin/DevelGenerate/MediaDevelGenerate.php
Method for creating media when number of elements is greater than 50.

File

devel_generate/devel_generate.batch.inc, line 20
Provides common batch functions for every DevelGeneratePlugin.

Code

function devel_generate_batch_finished($success, $results, $operations) {
  if ($success) {
    if (!empty($results['num_translations'])) {
      $message = t('Finished @num elements and @num_translations translations created successfully.', [
        '@num' => $results['num'],
        '@num_translations' => $results['num_translations'],
      ]);
    }
    else {
      $message = t('Finished @num elements created successfully.', [
        '@num' => $results['num'],
      ]);
    }
  }
  else {
    $message = t('Finished with an error.');
  }
  \Drupal::messenger()
    ->addMessage($message);
}