You are here

public static function DownloadTmgmtActionApproveForm::processBatch in TMGMT Extension Suite 8.3

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

Processes the sending batch.

Parameters

array $data: Keyed array of data to send.

array $context: The batch context.

Return value

\Drupal\tmgmt\JobInterface|mixed Returns TMGMT job on success and FALSE otherwise.

Overrides BaseTmgmtActionApproveForm::processBatch

File

src/Form/DownloadTmgmtActionApproveForm.php, line 44

Class

DownloadTmgmtActionApproveForm
Provides a confirmation form for sending multiple content entities.

Namespace

Drupal\tmgmt_extension_suit\Form

Code

public static function processBatch(array $data, array &$context) {
  $job = parent::processBatch($data, $context);
  if (!empty($job) && ($translator = $job
    ->getTranslator())) {
    $plugin = $translator
      ->getPlugin();
    if ($plugin instanceof ExtendedTranslatorPluginInterface && $plugin
      ->downloadTranslation($job)) {
      $context['results']['count']++;
    }
    else {
      $context['results']['errors'][] = new FormattableMarkup('Error downloading %name', [
        '%name' => $job
          ->label(),
      ]);
      return;
    }
    $context['message'] = new FormattableMarkup('Processed %name.', [
      '%name' => $job
        ->label(),
    ]);
  }
  else {
    $context['message'] = new FormattableMarkup('Skipped %name.', [
      '%name' => $data['entity_type'],
    ]);
  }
}