Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php \Drupal\Core\Entity\EntityDeleteFormTrait::getRedirectUrl()
  2. 9 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
This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form stateā€¦
4 methods override EntityDeleteFormTrait::getRedirectUrl()
DeleteForm::getRedirectUrl in core/modules/comment/src/Form/DeleteForm.php
Returns the URL where the user should be redirected after deletion.
MenuLinkContentDeleteForm::getRedirectUrl in core/modules/menu_link_content/src/Form/MenuLinkContentDeleteForm.php
Returns the URL where the user should be redirected after deletion.
ShortcutDeleteForm::getRedirectUrl in core/modules/shortcut/src/Form/ShortcutDeleteForm.php
Returns the URL where the user should be redirected after deletion.
TermDeleteForm::getRedirectUrl in core/modules/taxonomy/src/Form/TermDeleteForm.php
Returns the URL where the user should be redirected after deletion.

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>');
  }
}