You are here

protected function EntityCloneForm::formSetRedirect in Entity Clone 8

Sets a redirect on form state.

Parameters

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

\Drupal\Core\Entity\EntityInterface $entity: The cloned entity.

2 calls to EntityCloneForm::formSetRedirect()
EntityCloneForm::cancelForm in src/Form/EntityCloneForm.php
Cancel form handler.
EntityCloneForm::submitForm in src/Form/EntityCloneForm.php
Form submission handler.

File

src/Form/EntityCloneForm.php, line 241

Class

EntityCloneForm
Implements an entity Clone form.

Namespace

Drupal\entity_clone\Form

Code

protected function formSetRedirect(FormStateInterface $form_state, EntityInterface $entity) {
  if ($entity && $entity
    ->hasLinkTemplate('canonical')) {
    $form_state
      ->setRedirect($entity
      ->toUrl()
      ->getRouteName(), $entity
      ->toUrl()
      ->getRouteParameters());
  }
  else {
    $form_state
      ->setRedirect('<front>');
  }
}