CancelTmgmtActionApproveForm.php in TMGMT Extension Suite 8.3
File
src/Form/CancelTmgmtActionApproveForm.php
View source
<?php
namespace Drupal\tmgmt_extension_suit\Form;
use Drupal\Component\Render\FormattableMarkup;
class CancelTmgmtActionApproveForm extends BaseTmgmtActionApproveForm {
protected $tempStorageName = 'tmgmt_extension_suit_tmgmt_job_operations_cancel';
public function getFormId() {
return 'tmgmt_extension_suit_cancel_multiple_confirm';
}
public function getConfirmText() {
return $this
->t('Cancel Jobs');
}
public function getQuestion() {
return $this
->t('Are you sure you want to cancel these jobs?');
}
public function getDescription() {
return $this
->t('Canceling can take some time, do not close the browser');
}
public static function processBatch(array $data, array &$context) {
$job = parent::processBatch($data, $context);
if (!empty($job) && !$job
->abortTranslation()) {
$context['results']['count']++;
foreach ($job
->getMessagesSince() as $message) {
if ($message
->getType() == 'debug') {
continue;
}
if ($text = $message
->getMessage()) {
\Drupal::messenger()
->addMessage($text, $message
->getType());
}
}
}
else {
$context['results']['errors'][] = new FormattableMarkup('Error aborting %name', [
'%name' => $job
->label(),
]);
return;
}
$context['message'] = new FormattableMarkup('Processed %name.', [
'%name' => $job
->label(),
]);
}
}