You are here

public function SettingsForm::submitForm in Stage File Proxy 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/SettingsForm.php, line 128

Class

SettingsForm
Provide settings for Stage File Proxy.

Namespace

Drupal\stage_file_proxy\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('stage_file_proxy.settings');
  $keys = [
    'origin',
    'origin_dir',
    'use_imagecache_root',
    'hotlink',
    'verify',
  ];
  foreach ($keys as $key) {
    $value = $form_state
      ->getValue($key);
    if ($key === 'origin') {
      $value = trim($value, '/ ');
    }
    $config
      ->set($key, $value);
  }
  $config
    ->save();
  $this
    ->messenger()
    ->addMessage($this
    ->t('Your settings have been saved.'));
}