public function BaseTmgmtActionApproveForm::submitForm in TMGMT Extension Suite 8.3
Same name and namespace in other branches
- 8 src/Form/BaseTmgmtActionApproveForm.php \Drupal\tmgmt_extension_suit\Form\BaseTmgmtActionApproveForm::submitForm()
- 8.2 src/Form/BaseTmgmtActionApproveForm.php \Drupal\tmgmt_extension_suit\Form\BaseTmgmtActionApproveForm::submitForm()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
1 method overrides BaseTmgmtActionApproveForm::submitForm()
- RequestTranslationTmgmtActionApproveForm::submitForm in src/
Form/ RequestTranslationTmgmtActionApproveForm.php - Form submit.
File
- src/
Form/ BaseTmgmtActionApproveForm.php, line 184
Class
- BaseTmgmtActionApproveForm
- Provides a confirmation form for sending multiple content entities.
Namespace
Drupal\tmgmt_extension_suit\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$current_user_id = $this
->currentUser()
->id();
$temp_storage_name = $this
->getTempStorageName();
// Clear out the accounts from the temp store.
$this->tempStoreFactory
->get($temp_storage_name)
->delete($current_user_id);
if (!$form_state
->getValue('confirm')) {
return;
}
// @TODO: change this when we add the support for queues.
$is_batch = TRUE;
$operations = [];
foreach ($this->entityIds as $id => $entity_type) {
// Make sure all submissions exists.
$item_data = [
'entity_type' => $entity_type,
'entity_id' => $id,
];
if ($is_batch) {
$operations[] = [
[
get_class($this),
'processBatch',
],
[
$item_data,
],
];
}
else {
$this->queue
->createItem($item_data);
}
}
if ($is_batch && $operations) {
$batch = [
'title' => $this
->getConfirmText(),
'operations' => $operations,
'finished' => [
get_class($this),
'finishBatch',
],
];
batch_set($batch);
}
else {
$form_state
->setRedirect('system.admin_content');
}
}