public function SetupForm::submitForm in Acquia Connector 8
Same name and namespace in other branches
- 8.2 src/Form/SetupForm.php \Drupal\acquia_connector\Form\SetupForm::submitForm()
- 3.x src/Form/SetupForm.php \Drupal\acquia_connector\Form\SetupForm::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 ConfigFormBase::submitForm
File
- src/
Form/ SetupForm.php, line 186
Class
- SetupForm
- Acquia Connector setup form.
Namespace
Drupal\acquia_connector\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$form_data = $form_state
->getStorage();
if (isset($form_data['choose']) && isset($form_data['response']['subscription'][$form_state
->getValue('subscription')])) {
$config = $this
->config('acquia_connector.settings');
$sub = $form_data['response']['subscription'][$form_state
->getValue('subscription')];
$config
->set('subscription_name', $sub['name'])
->save();
$storage = new Storage();
$storage
->setKey($sub['key']);
$storage
->setIdentifier($sub['identifier']);
}
else {
$this
->automaticStartSubmit($form_state);
}
// Don't set message or redirect if multistep.
if (!$form_state
->getErrors() && $form_state
->isRebuilding() === FALSE) {
// Check subscription and send a heartbeat to Acquia via XML-RPC.
// Our status gets updated locally via the return data.
$subscription = new Subscription();
$subscription_data = $subscription
->update();
// Redirect to the path without the suffix.
if ($subscription_data) {
$form_state
->setRedirect('acquia_connector.settings');
}
if ($subscription_data['active']) {
$this
->messenger()
->addStatus($this
->t('<h3>Connection successful!</h3>You are now connected to Acquia Cloud. Please enter a name for your site to begin sending profile data.'));
drupal_flush_all_caches();
}
}
}