protected function SetupForm::automaticStartSubmit in Acquia Connector 8
Same name and namespace in other branches
- 8.2 src/Form/SetupForm.php \Drupal\acquia_connector\Form\SetupForm::automaticStartSubmit()
- 3.x src/Form/SetupForm.php \Drupal\acquia_connector\Form\SetupForm::automaticStartSubmit()
Submit automatically if one subscription found.
Parameters
\Drupal\Core\Form\FormStateInterface $form_state: Form state.
1 call to SetupForm::automaticStartSubmit()
- SetupForm::submitForm in src/
Form/ SetupForm.php - Form submission handler.
File
- src/
Form/ SetupForm.php, line 226
Class
- SetupForm
- Acquia Connector setup form.
Namespace
Drupal\acquia_connector\FormCode
protected function automaticStartSubmit(FormStateInterface &$form_state) {
$config = $this
->config('acquia_connector.settings');
$storage = $form_state
->getStorage();
if (empty($storage['response']['subscription'])) {
$this
->messenger()
->addError($this
->t('No subscriptions were found for your account.'));
}
elseif (count($storage['response']['subscription']) > 1) {
// Multistep form for choosing from available subscriptions.
$storage['choose'] = TRUE;
// Force rebuild with next step.
$form_state
->setRebuild(TRUE);
$form_state
->setStorage($storage);
}
else {
// One subscription so set id/key pair.
$sub = $storage['response']['subscription'][0];
$config
->set('subscription_name', $sub['name'])
->save();
$storage = new Storage();
$storage
->setKey($sub['key']);
$storage
->setIdentifier($sub['identifier']);
}
}