public UserMultipleCancelConfirm::submitForm(array &$form, FormStateInterface $form_state)
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
- core/modules/user/src/Form/UserMultipleCancelConfirm.php, line 167
Class
- UserMultipleCancelConfirm
- Provides a confirmation form for cancelling multiple user accounts.
Namespace
Drupal\user\Form
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | public function submitForm( array & $form , FormStateInterface $form_state ) { $current_user_id = $this ->currentUser()->id(); // Clear out the accounts from the temp store. $this ->tempStoreFactory->get( 'user_user_operations_cancel' )-> delete ( $current_user_id ); if ( $form_state ->getValue( 'confirm' )) { foreach ( $form_state ->getValue( 'accounts' ) as $uid => $value ) { // Prevent programmatic form submissions from cancelling user 1. if ( $uid <= 1) { continue ; } // Prevent user administrators from deleting themselves without confirmation. if ( $uid == $current_user_id ) { $admin_form_mock = array (); $admin_form_state = $form_state ; $admin_form_state ->unsetValue( 'user_cancel_confirm' ); // The $user global is not a complete user entity, so load the full // entity. $account = $this ->userStorage->load( $uid ); $admin_form = $this ->entityManager->getFormObject( 'user' , 'cancel' ); $admin_form ->setEntity( $account ); // Calling this directly required to init form object with $account. $admin_form ->buildForm( $admin_form_mock , $admin_form_state ); $admin_form ->submitForm( $admin_form_mock , $admin_form_state ); } else { user_cancel( $form_state ->getValues(), $uid , $form_state ->getValue( 'user_cancel_method' )); } } } $form_state ->setRedirect( 'entity.user.collection' ); } |
Please login to continue.