You are here

public function WebformSubmissionDeleteForm::getCancelUrl in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Form/WebformSubmissionDeleteForm.php \Drupal\webform\Form\WebformSubmissionDeleteForm::getCancelUrl()

Returns the route to go to if the user cancels the action.

Return value

\Drupal\Core\Url A URL object.

Overrides ContentEntityDeleteForm::getCancelUrl

1 call to WebformSubmissionDeleteForm::getCancelUrl()
WebformSubmissionDeleteForm::getRedirectUrl in src/Form/WebformSubmissionDeleteForm.php
Returns the URL where the user should be redirected after deletion.

File

src/Form/WebformSubmissionDeleteForm.php, line 162

Class

WebformSubmissionDeleteForm
Provides a confirmation webform for deleting a webform submission.

Namespace

Drupal\webform\Form

Code

public function getCancelUrl() {
  if ($this->webform
    ->access('submission_view_own') || $this->webform
    ->access('submission_view_any')) {
    $base_route_name = strpos(\Drupal::routeMatch()
      ->getRouteName(), 'webform.user.submission.delete') !== FALSE ? 'webform.user.submissions' : 'webform.results_submissions';
    return $this->requestHandler
      ->getUrl($this->webform, $this->sourceEntity, $base_route_name);
  }
  elseif ($this->sourceEntity && $this->sourceEntity
    ->hasLinkTemplate('canonical') && $this->sourceEntity
    ->access('view')) {
    return $this->sourceEntity
      ->toUrl();
  }
  elseif ($this->webform
    ->access('view')) {
    return $this->webform
      ->toUrl();
  }
  else {
    return Url::fromRoute('<front>');
  }
}