ProcessFormExtra.php in Module Builder 8.3
File
module_builder_devel/src/Form/ProcessFormExtra.php
View source
<?php
namespace Drupal\module_builder_devel\Form;
use Drupal\module_builder\Form\ProcessForm;
use Drupal\Core\Form\FormStateInterface;
class ProcessFormExtra extends ProcessForm {
public static function batchOperation($job_batch, &$context) {
if (!isset($context['results']['start_time'])) {
$context['results']['start_time'] = \Drupal::time()
->getRequestTime();
}
parent::batchOperation($job_batch, $context);
}
public static function batchFinished($success, $results, $operations) {
parent::batchFinished($success, $results, $operations);
$start_time = $results['start_time'];
$end_time = \Drupal::time()
->getRequestTime();
$duration = $end_time - $start_time;
\Drupal::messenger()
->addStatus(t("Code analysis took @minutes minutes @seconds seconds.", [
'@minutes' => floor($duration / 60),
'@seconds' => $duration % 60,
]));
}
}