You are here

public function SamlauthAuthmapDeleteForm::submitForm in SAML Authentication 8.3

Same name and namespace in other branches
  1. 4.x src/Form/SamlauthAuthmapDeleteForm.php \Drupal\samlauth\Form\SamlauthAuthmapDeleteForm::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

src/Form/SamlauthAuthmapDeleteForm.php, line 117

Class

SamlauthAuthmapDeleteForm
Confirm the user wants to delete an authmap entry.

Namespace

Drupal\samlauth\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $uid = $this
    ->getRouteMatch()
    ->getParameter('uid');
  if (!$uid || filter_var($uid, FILTER_VALIDATE_INT) === FALSE) {
    throw new \LogicException('It should be impossible to submit this form without valid uid parameter.');
  }
  $this->connection
    ->delete('authmap')
    ->condition('uid', (int) $uid)
    ->condition('provider', 'samlauth')
    ->execute();
  $this
    ->messenger()
    ->addStatus($this
    ->t('The link has been deleted.'));
  $form_state
    ->setRedirectUrl($this
    ->getCancelUrl());
}