You are here

public function AddToAnySettingsForm::submitForm in AddToAny 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/AddToAnySettingsForm.php, line 263

Class

AddToAnySettingsForm
Configure AddToAny settings for this site.

Namespace

Drupal\addtoany\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $values = $form_state
    ->getValues();
  $this
    ->config('addtoany.settings')
    ->set('additional_css', $values['addtoany_additional_css'])
    ->set('additional_html', $values['addtoany_additional_html'])
    ->set('additional_js', $values['addtoany_additional_js'])
    ->set('buttons_size', $values['addtoany_buttons_size'])
    ->set('custom_universal_button', $values['addtoany_custom_universal_button'])
    ->set('universal_button', $values['addtoany_universal_button'])
    ->set('universal_button_placement', $values['addtoany_universal_button_placement']);
  foreach (self::getContentEntities() as $entity) {
    $entityId = $entity
      ->id();
    $this
      ->config('addtoany.settings')
      ->set("entities.{$entityId}", $values[$entityId]);
  }
  $this
    ->config('addtoany.settings')
    ->save();
  parent::submitForm($form, $form_state);
}