WebformSubmissionDuplicateForm.php in Webform 8.5
File
src/WebformSubmissionDuplicateForm.php
View source
<?php
namespace Drupal\webform;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
class WebformSubmissionDuplicateForm extends WebformSubmissionForm {
protected function prepareEntity() {
$this
->setEntity($this
->getEntity()
->createDuplicate());
parent::prepareEntity();
}
protected function setConfirmation(FormStateInterface $form_state) {
parent::setConfirmation($form_state);
$redirect = $form_state
->getRedirect();
$route_name = $this
->getRouteMatch()
->getRouteName();
if ($redirect instanceof Url && $redirect
->getRouteName() === $route_name) {
$webform_submission = $this->entity;
$source_entity = $webform_submission
->getSourceEntity();
$redirect_url = $this->requestHandler
->getUrl($webform_submission, $source_entity, 'webform_submission.canonical');
$form_state
->setRedirectUrl($redirect_url);
}
}
}