You are here

public function SettingsForm::submitForm in Sophron 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 306

Class

SettingsForm
Main Sophron settings admin form.

Namespace

Drupal\sophron\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this->configFactory
    ->getEditable('sophron.settings');
  try {
    $config
      ->set('map_option', $form_state
      ->getValue('map_option'));
    $config
      ->set('map_class', $form_state
      ->getValue('map_class'));
    $commands = Yaml::parse($form_state
      ->getValue('map_commands'));
    $config
      ->set('map_commands', $commands ?: []);
    $config
      ->save();
  } catch (\Exception $e) {

    // Do nothing.
  }
  parent::submitForm($form, $form_state);
}