You are here

public function SpiChangeForm::submitForm in Acquia Connector 8

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

Class

SpiChangeForm
Change SPI Data form.

Namespace

Drupal\acquia_connector\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $values = $form_state
    ->getValues();
  $config = $this
    ->configFactory()
    ->getEditable('acquia_connector.settings');
  if (isset($values['env_change_action']['unblock']) && $values['env_change_action']['unblock'] == 'unblock') {
    $config
      ->set('spi.environment_changed_action', $values['env_change_action']['unblock'])
      ->save();
  }
  else {
    $config
      ->set('spi.environment_changed_action', $values['env_change_action'])
      ->save();
  }
  if ($values['env_change_action'] == 'create') {
    $this->state
      ->set('spi.site_name', $values['name']);
    $this->state
      ->set('spi.site_machine_name', $values['machine_name']);
  }
  parent::submitForm($form, $form_state);

  // Send information as soon as the key/identifier pair is submitted.
  $response = \Drupal::service('acquia_connector.spi')
    ->sendFullSpi(ACQUIA_CONNECTOR_ACQUIA_SPI_METHOD_CREDS);
  \Drupal::service('acquia_connector.spi')
    ->spiProcessMessages($response);
  $form_state
    ->setRedirect('system.status');
}