You are here

public function ResponsiveShareButtonsForm::submitForm in Responsive Share Buttons 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/ResponsiveShareButtonsForm.php, line 99

Class

ResponsiveShareButtonsForm
Responsive share buttons configuration form.

Namespace

Drupal\responsive_share_buttons\Form

Code

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

  // Get the existing configuration.
  $config = $this
    ->config('responsive_share_buttons.settings');
  $networks = $config
    ->get('networks');
  $values = $form_state
    ->getValues();
  uasort($networks, [
    'Drupal\\Component\\Utility\\SortArray',
    'sortByWeightElement',
  ]);
  $config
    ->set('networks', $values['networks'])
    ->set('twitter_name', $form_state
    ->getValue('twitter_name'))
    ->save();
  drupal_flush_all_caches();
  parent::submitForm($form, $form_state);
}