function EntityDeleteFormTrait::getCancelUrl

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php \Drupal\Core\Entity\EntityDeleteFormTrait::getCancelUrl()

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.