You are here

public function MergeTermsTarget::submitForm in Term Merge 8

Plugin annotation

@SuppressWarnings(camelCase);

Overrides FormInterface::submitForm

File

src/Form/MergeTermsTarget.php, line 146

Class

MergeTermsTarget
Term merge target terms form.

Namespace

Drupal\term_merge\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  if (!empty($form_state
    ->getValue('new'))) {
    $this
      ->getTempStore()
      ->set('target', $form_state
      ->getValue('new'));
  }
  if (!empty($form_state
    ->getValue('existing'))) {
    $term = $this->termStorage
      ->load($form_state
      ->getValue('existing'));
    $this
      ->getTempStore()
      ->set('target', $term);
  }
  $routeName = 'entity.taxonomy_vocabulary.merge_confirm';
  $routeParameters['taxonomy_vocabulary'] = $this->vocabulary
    ->id();
  $form_state
    ->setRedirect($routeName, $routeParameters);
}