function EntityDeleteFormTrait::getRedirectUrl

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php \Drupal\Core\Entity\EntityDeleteFormTrait::getRedirectUrl()
  2. 10 core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php \Drupal\Core\Entity\EntityDeleteFormTrait::getRedirectUrl()
  3. 9 core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php \Drupal\Core\Entity\EntityDeleteFormTrait::getRedirectUrl()
  4. 8.9.x core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php \Drupal\Core\Entity\EntityDeleteFormTrait::getRedirectUrl()

Returns the URL where the user should be redirected after deletion.

Return value

\Drupal\Core\Url The redirect URL.

1 call to EntityDeleteFormTrait::getRedirectUrl()
ContentEntityDeleteForm::submitForm in core/lib/Drupal/Core/Entity/ContentEntityDeleteForm.php
4 methods override EntityDeleteFormTrait::getRedirectUrl()
DeleteForm::getRedirectUrl in core/modules/comment/src/Form/DeleteForm.php
MenuLinkContentDeleteForm::getRedirectUrl in core/modules/menu_link_content/src/Form/MenuLinkContentDeleteForm.php
ShortcutDeleteForm::getRedirectUrl in core/modules/shortcut/src/Form/ShortcutDeleteForm.php
TermDeleteForm::getRedirectUrl in core/modules/taxonomy/src/Form/TermDeleteForm.php

File

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

Class

EntityDeleteFormTrait
Provides a trait for an entity deletion form.

Namespace

Drupal\Core\Entity

Code

protected function getRedirectUrl() {
  $entity = $this->getEntity();
  if ($entity->hasLinkTemplate('collection')) {
    // If available, return the collection URL.
    return $entity->toUrl('collection');
  }
  else {
    // Otherwise fall back to the front page.
    return Url::fromRoute('<front>');
  }
}

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