You are here

public function BakeryPullForm::submitForm in Bakery Single Sign-On System 8.2

If the request succeeds, go to the user page. O5:1therwise, show an error.

Overrides FormInterface::submitForm

File

src/Forms/BakeryPullForm.php, line 83

Class

BakeryPullForm
Contribute form.

Namespace

Drupal\bakery\Forms

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $result = $this->service
    ->requestAccount($form_state
    ->getValue('name'), $form_state
    ->getValue('or_email'));
  if ($result === FALSE) {
    $this
      ->messenger()
      ->addError($this
      ->t("Pulling account %name failed: maybe there is a typo or they don't exist on the master site.", [
      '%name' => $form_state
        ->getValue('name'),
    ]));
  }
  else {
    $form_state
      ->setRedirect('user', [
      'id' => $result,
    ]);
  }
}