You are here

public function BrightcoveProxyForm::submitForm in Brightcove Video Connect 8

Same name and namespace in other branches
  1. 8.2 modules/brightcove_proxy/src/Form/BrightcoveProxyForm.php \Drupal\brightcove_proxy\Form\BrightcoveProxyForm::submitForm()
  2. 3.x modules/brightcove_proxy/src/Form/BrightcoveProxyForm.php \Drupal\brightcove_proxy\Form\BrightcoveProxyForm::submitForm()

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

modules/brightcove_proxy/src/Form/BrightcoveProxyForm.php, line 149

Class

BrightcoveProxyForm
Builds form for the Brightcove Proxy settings.

Namespace

Drupal\brightcove_proxy\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('brightcove_proxy.config')
    ->set('use_proxy', $form_state
    ->getValue('use_proxy'));

  // Set proxy values.
  if ($form_state
    ->getValue('use_proxy')) {
    foreach (array_keys($form['proxy_config']) as $config_name) {
      if (strpos($config_name, '#') === 0) {
        continue;
      }
      $config
        ->set($config_name, $form_state
        ->getValue($config_name));
    }
  }
  else {
    foreach (array_keys($form['proxy_config']) as $config_name) {
      if (strpos($config_name, '#') === 0) {
        continue;
      }
      $config
        ->set($config_name, NULL);
    }
  }
  $config
    ->save();
  parent::submitForm($form, $form_state);
}