public function LockrRegisterForm::submitForm in Lockr 8.3
Same name and namespace in other branches
- 8.4 src/Form/LockrRegisterForm.php \Drupal\lockr\Form\LockrRegisterForm::submitForm()
- 8.2 src/Form/LockrRegisterForm.php \Drupal\lockr\Form\LockrRegisterForm::submitForm()
- 4.x src/Form/LockrRegisterForm.php \Drupal\lockr\Form\LockrRegisterForm::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/ LockrRegisterForm.php, line 146
Class
- LockrRegisterForm
- Form handler for Lockr registration.
Namespace
Drupal\lockr\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$client_token = $form_state
->getValue('client_token');
$partner = $this->settingsFactory
->getPartner();
try {
if (is_null($partner)) {
$dn = [
'countryName' => 'US',
'stateOrProvinceName' => 'Washington',
'localityName' => 'Tacoma',
'organizationName' => 'Lockr',
];
$result = $this->lockr
->createCertClient($client_token, $dn);
CertWriter::writeCerts('dev', $result);
$config = $this->configFactory
->getEditable('lockr.settings');
$config
->set('custom', TRUE);
$config
->set('cert_path', 'private://lockr/dev/pair.pem');
$config
->save();
}
elseif ($partner['name'] === 'pantheon') {
$this->lockr
->createPantheonClient($client_token);
}
} catch (\Exception $e) {
// XXX: probably log and/or show message
throw $e;
return;
}
$this->messenger
->addMessage($this
->t("That's it! You're signed up with Lockr; your keys are now safe."));
$form_state
->setRedirect('entity.key.collection');
}