public function ExportUserConfirm::submitForm in Open Social 8
Same name and namespace in other branches
- 8.2 modules/social_features/social_user_export/src/Form/ExportUserConfirm.php \Drupal\social_user_export\Form\ExportUserConfirm::submitForm()
- 8.3 modules/social_features/social_user_export/src/Form/ExportUserConfirm.php \Drupal\social_user_export\Form\ExportUserConfirm::submitForm()
- 8.4 modules/social_features/social_user_export/src/Form/ExportUserConfirm.php \Drupal\social_user_export\Form\ExportUserConfirm::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
File
- modules/
social_features/ social_user_export/ src/ Form/ ExportUserConfirm.php, line 158
Class
- ExportUserConfirm
- Class ExportUserConfirm.
Namespace
Drupal\social_user_export\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$export_params = $form_state
->get('export_params');
if ($form_state
->getValue('confirm')) {
// Define the batch.
$batch = [
'title' => t('Exporting users'),
'operations' => [],
'finished' => [
'\\Drupal\\social_user_export\\ExportUser',
'finishedCallback',
],
];
// If selected all users, add single massive operation,
// else add one operation for each user.
if ($export_params['apply_all']) {
$batch['operations'][] = [
[
'\\Drupal\\social_user_export\\ExportUser',
'exportUsersAllOperation',
],
[
$export_params['query'],
],
];
}
else {
foreach ($export_params['accounts'] as $uid) {
$batch['operations'][] = [
[
'\\Drupal\\social_user_export\\ExportUser',
'exportUserOperation',
],
[
User::load($uid),
],
];
}
$batch['operations'] = array_reverse($batch['operations']);
}
batch_set($batch);
}
$form_state
->setRedirect('entity.user.collection');
}