function EntityDeleteFormTrait::getCancelUrl

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php \Drupal\Core\Entity\EntityDeleteFormTrait::getCancelUrl()
  2. 10 core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php \Drupal\Core\Entity\EntityDeleteFormTrait::getCancelUrl()
  3. 11.x 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();
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.