public function UserLoginForm::submitForm in Drupal 9
Same name and namespace in other branches
- 8 core/modules/user/src/Form/UserLoginForm.php \Drupal\user\Form\UserLoginForm::submitForm()
- 10 core/modules/user/src/Form/UserLoginForm.php \Drupal\user\Form\UserLoginForm::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
- core/
modules/ user/ src/ Form/ UserLoginForm.php, line 138
Class
- UserLoginForm
- Provides a user login form.
Namespace
Drupal\user\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
if (empty($uid = $form_state
->get('uid'))) {
return;
}
$account = $this->userStorage
->load($uid);
// A destination was set, probably on an exception controller.
if (!$this
->getRequest()->request
->has('destination')) {
$form_state
->setRedirect('entity.user.canonical', [
'user' => $account
->id(),
]);
}
else {
$this
->getRequest()->query
->set('destination', $this
->getRequest()->request
->get('destination'));
}
user_login_finalize($account);
}