You are here

public function RenameAdminPathsSettingsForm::submitForm in Rename Admin Paths 8

Same name and namespace in other branches
  1. 8.2 src/Form/RenameAdminPathsSettingsForm.php \Drupal\rename_admin_paths\Form\RenameAdminPathsSettingsForm::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/RenameAdminPathsSettingsForm.php, line 82

Class

RenameAdminPathsSettingsForm
Implements an example form.

Namespace

Drupal\rename_admin_paths\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  // Save configuration.
  $config = \Drupal::service('config.factory')
    ->getEditable('rename_admin_paths.settings');
  $config
    ->set('admin_path', $form_state
    ->getValue('admin_path'));
  $config
    ->set('admin_path_value', $form_state
    ->getValue('admin_path_value'));
  $config
    ->set('user_path', $form_state
    ->getValue('user_path'));
  $config
    ->set('user_path_value', $form_state
    ->getValue('user_path_value'));
  $config
    ->save();

  // Rebuild routes.
  \Drupal::service('router.builder')
    ->rebuild();
}