You are here

public function TaxonomyEntityIndexAdminForm::submitForm in Taxonomy Entity Index 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/TaxonomyEntityIndexAdminForm.php, line 109

Class

TaxonomyEntityIndexAdminForm
Provides the primary settings form.

Namespace

Drupal\taxonomy_entity_index\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $settings = [
    'types' => array_filter($form_state
      ->getValue([
      'types',
    ])),
    'index_revisions' => $form_state
      ->getValue([
      'index_revisions',
    ]),
    'index_per_field' => $form_state
      ->getValue([
      'index_per_field',
    ]),
  ];
  $config = $this
    ->config('taxonomy_entity_index.settings');
  foreach ($settings as $key => $value) {
    $config
      ->set($key, $value);
  }
  $config
    ->save();
  $this
    ->messenger()
    ->addMessage($this
    ->t('The settings have been saved.'));
}