DownloadTmgmtActionApproveForm.php in TMGMT Extension Suite 8.3
File
src/Form/DownloadTmgmtActionApproveForm.php
View source
<?php
namespace Drupal\tmgmt_extension_suit\Form;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\tmgmt_extension_suit\ExtendedTranslatorPluginInterface;
class DownloadTmgmtActionApproveForm extends BaseTmgmtActionApproveForm {
public function getFormId() {
return 'tmgmt_extension_suit_download_multiple_confirm';
}
public function getConfirmText() {
return $this
->t('Download Translation');
}
public function getQuestion() {
return $this
->t('Are you sure you want to download translations for these jobs?');
}
public function getDescription() {
return $this
->t('Downloading 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) && ($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'],
]);
}
}
}