You are here

public function OpignoTincanApiSettingsForm::submitForm in Opigno TinCan API 8

Same name and namespace in other branches
  1. 3.x src/Form/OpignoTincanApiSettingsForm.php \Drupal\opigno_tincan_api\Form\OpignoTincanApiSettingsForm::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/OpignoTincanApiSettingsForm.php, line 64

Class

OpignoTincanApiSettingsForm
Class OpignoTincanApiSettingsForm.

Namespace

Drupal\opigno_tincan_api\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $messenger = \Drupal::messenger();
  $config = \Drupal::configFactory()
    ->getEditable('opigno_tincan_api.settings');
  $config
    ->set('opigno_tincan_api_endpoint', trim($form_state
    ->getValue('endpoint')));
  $config
    ->set('opigno_tincan_api_username', trim($form_state
    ->getValue('username')));
  $config
    ->set('opigno_tincan_api_password', trim($form_state
    ->getValue('password')));
  $config
    ->save();

  // TODO(tincan): In D7 here opigno_tincan_api_stats is enabling.
  $messenger
    ->addMessage($this
    ->t('LRS settings saved successfully'));
}