You are here

public function PathFormBase::submitForm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/path/src/Form/PathFormBase.php \Drupal\path\Form\PathFormBase::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 FormInterface::submitForm

File

core/modules/path/src/Form/PathFormBase.php, line 207
Contains \Drupal\path\Form\PathFormBase.

Class

PathFormBase
Provides a base class for path add/edit forms.

Namespace

Drupal\path\Form

Code

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

  // Remove unnecessary values.
  $form_state
    ->cleanValues();
  $pid = $form_state
    ->getValue('pid', 0);
  $source = $form_state
    ->getValue('source');
  $alias = $form_state
    ->getValue('alias');

  // Language is only set if language.module is enabled, otherwise save for all
  // languages.
  $langcode = $form_state
    ->getValue('langcode', LanguageInterface::LANGCODE_NOT_SPECIFIED);
  $this->aliasStorage
    ->save($source, $alias, $langcode, $pid);
  drupal_set_message($this
    ->t('The alias has been saved.'));
  $form_state
    ->setRedirect('path.admin_overview');
}