You are here

public function LdapAuthenticationProfileUpdateForm::submitForm in Lightweight Directory Access Protocol (LDAP) 8.4

Same name and namespace in other branches
  1. 8.3 ldap_authentication/src/Form/LdapAuthenticationProfileUpdateForm.php \Drupal\ldap_authentication\Form\LdapAuthenticationProfileUpdateForm::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

ldap_authentication/src/Form/LdapAuthenticationProfileUpdateForm.php, line 111

Class

LdapAuthenticationProfileUpdateForm
Profile update form.

Namespace

Drupal\ldap_authentication\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) : void {

  /** @var \Drupal\user\Entity\User $user */
  $user = $this->entityTypeManager
    ->getStorage('user')
    ->load($this->currentUser
    ->id());
  $user
    ->set('mail', $form_state
    ->getValue('mail'));
  $user
    ->save();
  $this
    ->messenger()
    ->addMessage($this
    ->t('Your profile has been updated.'));
  $form_state
    ->setRedirect('<front>');
}