You are here

public function DomainThemeSwitchConfigForm::submitForm in Domain Theme Switch 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/DomainThemeSwitchConfigForm.php, line 159

Class

DomainThemeSwitchConfigForm
Class DomainThemeSwitchConfigForm.

Namespace

Drupal\domain_theme_switch\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  parent::submitForm($form, $form_state);
  $domains = $this->entityTypeManager
    ->getStorage('domain')
    ->loadMultiple();
  $config = $this
    ->config('domain_theme_switch.settings');
  foreach ($domains as $domain) {
    $domainId = $domain
      ->id();
    $config
      ->set($domainId . '_site', $form_state
      ->getValue($domainId . '_site'));
    $config
      ->set($domainId . '_admin', $form_state
      ->getValue($domainId . '_admin'));
  }
  $config
    ->save();
}