8.5.x common.inc drupal_get_destination()
8.0.x common.inc drupal_get_destination()
8.1.x common.inc drupal_get_destination()
8.2.x common.inc drupal_get_destination()
8.3.x common.inc drupal_get_destination()
8.4.x common.inc drupal_get_destination()
8.6.x common.inc drupal_get_destination()
4.6.x common.inc drupal_get_destination()
4.7.x common.inc drupal_get_destination()
5.x common.inc drupal_get_destination()
6.x common.inc drupal_get_destination()
7.x common.inc drupal_get_destination()

Prepares a 'destination' URL query parameter.

Used to direct the user back to the referring page after completing a form. By default the current URL is returned. If a destination exists in the previous request, that destination is returned. As such, a destination can persist across multiple pages.

Return value

array An associative array containing the key:

  • destination: The value of the current request's 'destination' query parameter, if present. This can be either a relative or absolute URL. However, for security, redirection to external URLs is not performed. If the query parameter isn't present, then the URL of the current request is returned.

Deprecated

in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0. Use the redirect.destination service.

See also

\Drupal\Core\EventSubscriber\RedirectResponseSubscriber::checkRedirectUrl()

https://www.drupal.org/node/2448603

Related topics

File

core/includes/common.inc, line 159
Common functions that many Drupal modules will need to reference.

Code

function drupal_get_destination() {
  return \Drupal::destination()
    ->getAsArray();
}