How to know how many elements are processed in the finish callback? I followed Smack My Batch Up : Batch Processing In Drupal 8 article to create a batch job and all works fine. But in the finish callback I can't get the total number of processed elements.

This is my code:

$operations = [];
foreach ($lines as $line) {
/*
Here I have an array of operations and each element have the name of 
the operation callback function and the line that should be processed.
Maybe this is the problem.
*/
  $operations[] = ['process_line_saint_du_jour', [$line]];
}

$batch = array(
  'title' =&gt; t('Migrating Saint of the Day'),
  'operations' =&gt; $operations,
  'finished' =&gt; 'process_line_saint_du_jour_batch_finished',
  'init_message' =&gt; t('Saint of the Day migration is starting.'),
  'progress_message' =&gt; t('Processed @current out of @total. Estimated time: @estimate.'),
  'error_message' =&gt; t('The migration process has encountered an error.'),
  'file' =&gt; drupal_get_path('module', 'diocese_migrate') . '/diocese_migrate.batch.inc',
);

batch_set($batch);


This is my finish callback function:

function process_line_saint_du_jour_batch_finished($success, $results, $operations) {
  // The 'success' parameter means no fatal PHP errors were detected. All
  // other error management should be handled using 'results'.
  if ($success) {
    $message = \Drupal::translation()-&gt;formatPlural(
      count($results),
      'One Saint of the Day processed.', '@count Saint of the Day processed.'
    );
  }
  else {
    $message = t('Finished with an error.');
  }
  drupal_set_message($message);
}


The problem here is that I have only one element in the $results array and I have processed 366 elements, all works fine but at the end of the batch I have the following message:


  One Saint of the Day processed.
Reading the Batch Process in Drupal 8 and Drupal 8 Batch Example articles I found the answer.

The key is in the 

//Message to show during each execution of the callback function
$context['message']
//Array with the total of processed items.
$context['results']


So, the solution is in the operations callback function, now the functions is like this and it works:

function process_line_saint_du_jour($line, &amp;$context) {
  //Custom Code
  $info = str_getcsv($line, ";", '"');
  $context['results'][] = $info[3];
  $context['message'] = t('Migrating Saint du jour @day', array('@day' =&gt; $info[3]));
}