You are here

public function CustomDataForm::submitForm in Shibboleth Authentication 8

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

src/Form/CustomDataForm.php, line 109

Class

CustomDataForm
Class CustomEmailForm.

Namespace

Drupal\shib_auth\Form

Code

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

  // Start Session if it does not exist yet.
  if ($this->current_user
    ->isAnonymous() && !isset($_SESSION['session_started'])) {
    $_SESSION['session_started'] = TRUE;
    $this->session_manager
      ->start();
  }

  // Add custom Email to the session.
  $this->custom_data_store
    ->set('custom_email', $form_state
    ->getValue('email'));

  // Redirect.
  $form_state
    ->setRedirectUrl(Url::fromUri(\Drupal::request()
    ->getSchemeAndHttpHost() . $this->custom_data_store
    ->get('return_url')));
}