You are here

public function SettingsForm::submitForm in Acquia Connector 8

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

Class

SettingsForm
Acquia Connector Settings.

Namespace

Drupal\acquia_connector\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->configFactory()
    ->getEditable('acquia_connector.settings');
  $values = $form_state
    ->getValues();
  $this->state
    ->set('spi.site_name', $values['name']);
  $config
    ->set('spi.dynamic_banner', $values['acquia_dynamic_banner'])
    ->set('spi.admin_priv', $values['admin_priv'])
    ->set('spi.send_node_user', $values['send_node_user'])
    ->set('spi.send_watchdog', $values['send_watchdog'])
    ->set('spi.use_cron', $values['use_cron'])
    ->set('spi.set_variables_override', $values['alter_variables'])
    ->save();

  // If the machine name changed, send information so we know if it is a dupe.
  if ($values['machine_name'] != $this->state
    ->get('spi.site_machine_name')) {
    $this->state
      ->set('spi.site_machine_name', $values['machine_name']);
    $response = \Drupal::service('acquia_connector.spi')
      ->sendFullSpi(ACQUIA_CONNECTOR_ACQUIA_SPI_METHOD_CREDS);
    \Drupal::service('acquia_connector.spi')
      ->spiProcessMessages($response);
  }
  parent::submitForm($form, $form_state);
}