You are here

public function SettingsForm::submitForm in Twitter Profile Widget 3.x

Same name and namespace in other branches
  1. 8.2 src/Form/SettingsForm.php \Drupal\twitter_profile_widget\Form\SettingsForm::submitForm()
  2. 8 src/Form/SettingsForm.php \Drupal\twitter_profile_widget\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 84

Class

SettingsForm
Class SettingsForm.

Namespace

Drupal\twitter_profile_widget\Form

Code

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

  // Invalidate cached Twitter data for widget views.
  Cache::invalidateTags([
    'twitter_widget_view',
  ]);
  $values = $form_state
    ->getValues();
  Authorization::getToken($values['twitter_widget_key'], $values['twitter_widget_secret']);
  $this
    ->config('twitter_profile_widget.settings')
    ->set('expire_internal_cache', $values['expire_internal_cache'])
    ->set('twitter_widget_key', $values['twitter_widget_key'])
    ->set('twitter_widget_secret', $values['twitter_widget_secret'])
    ->set('twitter_widget_cache_time', $values['twitter_widget_cache_time'])
    ->save();
  parent::submitForm($form, $form_state);
}