You are here

public function LockrMigrateForm::submitForm in Lockr 8.3

Same name and namespace in other branches
  1. 8.4 src/Form/LockrMigrateForm.php \Drupal\lockr\Form\LockrMigrateForm::submitForm()
  2. 8.2 src/Form/LockrMigrateForm.php \Drupal\lockr\Form\LockrMigrateForm::submitForm()
  3. 4.x src/Form/LockrMigrateForm.php \Drupal\lockr\Form\LockrMigrateForm::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/LockrMigrateForm.php, line 131

Class

LockrMigrateForm
Form handler for Lockr move to production.

Namespace

Drupal\lockr\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $client_token = $form_state
    ->getValue('client_token');
  $dn = [
    'countryName' => 'US',
    'stateOrProvinceName' => 'Washington',
    'localityName' => 'Tacoma',
    'organizationName' => 'Lockr',
  ];
  try {
    $result = $this->lockr
      ->createCertClient($client_token, $dn);
    CertWriter::writeCerts('prod', $result);
    $config = $this->configFactory
      ->getEditable('lockr.settings');
    $config
      ->set('custom', TRUE);
    $config
      ->set('cert_path', 'private://lockr/prod/pair.pem');
    $config
      ->save();
  } catch (\Exception $e) {

    // XXX: probably log and/or show message
    throw $e;
    return;
  }
}