You are here

public function HighContrastConfigurationForm::submitForm in High contrast 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/HighContrastConfigurationForm.php, line 196

Class

HighContrastConfigurationForm
Class HighContrastConfigurationForm.

Namespace

Drupal\high_contrast\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  parent::submitForm($form, $form_state);
  $config = $this
    ->config('high_contrast.settings');
  $config
    ->set('colors_background', $form_state
    ->getValue('colors_background'));
  $config
    ->set('colors_text', $form_state
    ->getValue('colors_text'));
  $config
    ->set('colors_hyperlinks', $form_state
    ->getValue('colors_hyperlinks'));
  $config
    ->set('default_logo', $form_state
    ->getValue('default_logo'));
  $config
    ->set('logo_path', $form_state
    ->getValue('logo_path'));

  // If the user uploaded a new logo, save it to a permanent location and use
  // it in place of the default theme-provided file.
  if (!empty($form_state
    ->getValue('logo_upload'))) {
    $source = $form_state
      ->getValue('logo_upload')
      ->getFileUri();
    $destination = file_build_uri($this->fileSystem
      ->basename($source));
    $filename = $this->fileSystem
      ->copy($source, $destination);
    $config
      ->set('default_logo', 0);
    $config
      ->set('logo_path', $filename);
  }
  $config
    ->save();
}