public static function ClearJobItemsDataTmgmtActionApproveForm::processBatch in TMGMT Extension Suite 8
Same name and namespace in other branches
- 8.3 src/Form/ClearJobItemsDataTmgmtActionApproveForm.php \Drupal\tmgmt_extension_suit\Form\ClearJobItemsDataTmgmtActionApproveForm::processBatch()
- 8.2 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.
Overrides BaseTmgmtActionApproveForm::processBatch
File
- src/
Form/ ClearJobItemsDataTmgmtActionApproveForm.php, line 56
Class
- ClearJobItemsDataTmgmtActionApproveForm
- Provides a confirmation form for sending multiple content entities.
Namespace
Drupal\tmgmt_extension_suit\FormCode
public static function processBatch($data, &$context) {
if (!isset($context['results']['errors'])) {
$context['results']['errors'] = [];
$context['results']['count'] = 0;
}
$entity_type_id = $data['entity_type'];
$entity_id = $data['entity_id'];
$job = \Drupal::entityTypeManager()
->getStorage($entity_type_id)
->loadMultiple([
$entity_id,
]);
$job = reset($job);
if (!$job) {
$context['results']['errors'][] = t('Entity @entity_type:@entity_id not found', [
'@entity_type' => $entity_type_id,
'@entity_id' => $entity_id,
]);
}
else {
$context['results']['count']++;
foreach ($job
->getItems() as $job_item) {
$job_item
->resetData();
$job_item
->save();
}
}
$context['message'] = new FormattableMarkup('Processed %name.', [
'%name' => $job
->label(),
]);
}