You are here

public function SyntaxHighlighterSettingsForm::submitForm in Syntax Highlighter 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/SyntaxHighlighterSettingsForm.php, line 236

Class

SyntaxHighlighterSettingsForm
Configure Syntax Highlighter settings.

Namespace

Drupal\syntaxhighlighter\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('syntaxhighlighter.settings');
  $enabled_languages = array_keys(array_filter($form_state
    ->getValue('syntaxhighlighter_enabled_languages')));
  $config
    ->set('enabled_languages', $enabled_languages);
  $config
    ->set('use_autoloader', $form_state
    ->getValue('syntaxhighlighter_use_autoloader'));
  $config
    ->set('theme', $form_state
    ->getValue('syntaxhighlighter_theme'));
  $config
    ->set('tagname', $form_state
    ->getValue('syntaxhighlighter_tagname'));
  $config
    ->set('legacy_mode', $form_state
    ->getValue('syntaxhighlighter_legacy_mode'));
  $config
    ->set('inject', $form_state
    ->getValue('syntaxhighlighter_inject'));
  $config
    ->set('pages', $form_state
    ->getValue('syntaxhighlighter_pages'));
  $config
    ->set('default_expressions', $form_state
    ->getValue('syntaxhighlighter_default_expressions'));
  $config
    ->save();
  _syntaxhighlighter_setup_autoloader_script($config);
  parent::submitForm($form, $form_state);
}