You are here

public function JsonapiExtrasSettingsForm::submitForm in JSON:API Extras 8

Same name and namespace in other branches
  1. 8.3 src/Form/JsonapiExtrasSettingsForm.php \Drupal\jsonapi_extras\Form\JsonapiExtrasSettingsForm::submitForm()
  2. 8.2 src/Form/JsonapiExtrasSettingsForm.php \Drupal\jsonapi_extras\Form\JsonapiExtrasSettingsForm::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/JsonapiExtrasSettingsForm.php, line 83

Class

JsonapiExtrasSettingsForm
Configure JSON API settings for this site.

Namespace

Drupal\jsonapi_extras\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  if ($path_prefix = $form_state
    ->getValue('path_prefix')) {
    $this
      ->config('jsonapi_extras.settings')
      ->set('path_prefix', trim($path_prefix, '/'))
      ->save();
  }
  $this
    ->config('jsonapi_extras.settings')
    ->set('include_count', $form_state
    ->getValue('include_count'))
    ->save();

  // Rebuild the router.
  $this->routerBuilder
    ->setRebuildNeeded();
  parent::submitForm($form, $form_state);
}