You are here

public function PushNotificationsConfigForm::submitForm in Push Notifications 8

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/PushNotificationsConfigForm.php, line 155

Class

PushNotificationsConfigForm
Class PushNotificationsConfigForm.

Namespace

Drupal\push_notifications\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  // Store APNS config.
  $config_apns = $this
    ->config('push_notifications.apns');
  $config_apns
    ->set('environment', $form_state
    ->getValue('apns_environment'));
  $config_apns
    ->set('stream_context_limit', $form_state
    ->getValue('apns_stream_context_limit'));
  $config_apns
    ->set('passphrase', $form_state
    ->getValue('apns_passphrase'));
  $config_apns
    ->set('certificate_folder', $form_state
    ->getValue('apns_certificate_folder'));
  $config_apns
    ->set('set_entrust_certificate', $form_state
    ->getValue('apns_set_entrust_certificate'));
  $config_apns
    ->save();

  // Store GCM config.
  $config_gcm = $this
    ->config('push_notifications.gcm');
  $config_gcm
    ->set('api_key', $form_state
    ->getValue('gcm_api_key'));
  $config_gcm
    ->save();
}