You are here

public function EasyBreadcrumbGeneralSettingsForm::submitForm in Easy Breadcrumb 8

Same name and namespace in other branches
  1. 2.x src/Form/EasyBreadcrumbGeneralSettingsForm.php \Drupal\easy_breadcrumb\Form\EasyBreadcrumbGeneralSettingsForm::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

src/Form/EasyBreadcrumbGeneralSettingsForm.php, line 381

Class

EasyBreadcrumbGeneralSettingsForm
Build Easy Breadcrumb settings form.

Namespace

Drupal\easy_breadcrumb\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $settings = $this->configFactory
    ->getEditable(EasyBreadcrumbConstants::MODULE_SETTINGS);

  // Get the values.
  $values = $form_state
    ->cleanValues()
    ->getValues();

  // Convert words lists to arrays where required.
  $keys_to_process = [
    EasyBreadcrumbConstants::CAPITALIZATOR_IGNORED_WORDS,
    EasyBreadcrumbConstants::CAPITALIZATOR_FORCED_WORDS,
  ];
  foreach ($keys_to_process as $key) {
    $values[$key] = $this
      ->processValuesToArray($values[$key]);
  }
  foreach ($values as $field_key => $field_value) {
    $settings
      ->set($field_key, $field_value);
  }
  $settings
    ->save();
  parent::submitForm($form, $form_state);
}