You are here

public static function ClearJobItemsDataTmgmtActionApproveForm::processBatch in TMGMT Extension Suite 8.2

Same name and namespace in other branches
  1. 8.3 src/Form/ClearJobItemsDataTmgmtActionApproveForm.php \Drupal\tmgmt_extension_suit\Form\ClearJobItemsDataTmgmtActionApproveForm::processBatch()
  2. 8 src/Form/ClearJobItemsDataTmgmtActionApproveForm.php \Drupal\tmgmt_extension_suit\Form\ClearJobItemsDataTmgmtActionApproveForm::processBatch()

Processes the sending batch.

Parameters

array $data: Keyed array of data to send.

array $context: The batch context.

Return value

JobInterface|mixed

Overrides BaseTmgmtActionApproveForm::processBatch

File

src/Form/ClearJobItemsDataTmgmtActionApproveForm.php, line 51

Class

ClearJobItemsDataTmgmtActionApproveForm
Provides a confirmation form for sending multiple content entities.

Namespace

Drupal\tmgmt_extension_suit\Form

Code

public static function processBatch($data, &$context) {
  $job = parent::processBatch($data, $context);
  if (!empty($job)) {
    $context['results']['count']++;
    foreach ($job
      ->getItems() as $job_item) {
      $job_item
        ->resetData();
      $job_item
        ->save();
    }
    $context['message'] = new FormattableMarkup('Processed %name.', [
      '%name' => $job
        ->label(),
    ]);
  }
  else {
    $context['message'] = new FormattableMarkup('Skipped %name.', [
      '%name' => $data['entity_type'],
    ]);
  }
}