return $form;
} /**
* {@inheritdoc}
*/
public function submitForm(array &
$form, FormStateInterface
$form_state) { // Cancel account immediately, if the current user has administrative
// privileges, no confirmation mail shall be sent, and the user does not
// attempt to cancel the own account.
if (!
$form_state->
isValueEmpty('access'
) &&
$form_state->
isValueEmpty('user_cancel_confirm'
) &&
$this->entity->
id() !=
$this->
currentUser()->
id()) { user_cancel($form_state->
getValues(),
$this->entity->
id(),
$form_state->
getValue('user_cancel_method'
));
$form_state->
setRedirectUrl($this->entity->
toUrl('collection'
));
} else { // Store cancelling method and whether to notify the user in
// $this->entity for
// \Drupal\user\Controller\UserController::confirmCancel().
$this->entity->user_cancel_method =
$form_state->
getValue('user_cancel_method'
);
$this->entity->user_cancel_notify =
$form_state->
getValue('user_cancel_notify'
);
$this->entity->
save();