You are here

public function EntityDeleteFormTrait::getCancelUrl in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php \Drupal\Core\Entity\EntityDeleteFormTrait::getCancelUrl()
  2. 9 core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php \Drupal\Core\Entity\EntityDeleteFormTrait::getCancelUrl()
2 calls to EntityDeleteFormTrait::getCancelUrl()
ContentEntityDeleteForm::getCancelUrl in core/lib/Drupal/Core/Entity/ContentEntityDeleteForm.php
Returns the route to go to if the user cancels the action.
EntityDeleteFormTrait::submitForm in core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php
3 methods override EntityDeleteFormTrait::getCancelUrl()
ActionDeleteForm::getCancelUrl in core/modules/action/src/Form/ActionDeleteForm.php
BlockDeleteForm::getCancelUrl in core/modules/block/src/Form/BlockDeleteForm.php
FieldConfigDeleteForm::getCancelUrl in core/modules/field_ui/src/Form/FieldConfigDeleteForm.php

File

core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php, line 77

Class

EntityDeleteFormTrait
Provides a trait for an entity deletion form.

Namespace

Drupal\Core\Entity

Code

public function getCancelUrl() {
  $entity = $this
    ->getEntity();
  if ($entity
    ->hasLinkTemplate('collection')) {

    // If available, return the collection URL.
    return $entity
      ->toUrl('collection');
  }
  else {

    // Otherwise fall back to the default link template.
    return $entity
      ->toUrl();
  }
}