3 namespace Drupal\Core\Routing;
6 * Provides an interface for redirect destinations.
8 interface RedirectDestinationInterface {
11 * Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url.
13 * Used to direct the user back to the referring page after completing a form.
14 * By default the current URL is returned. If a destination exists in the
15 * current request, that destination is returned. As such, a destination can
16 * persist across multiple pages.
19 * An associative array containing the key:
20 * - destination: The value of the current request's 'destination' query
21 * parameter, if present. This can be either a relative or absolute URL.
22 * However, for security, redirection to external URLs is not performed.
23 * If the query parameter isn't present, then the URL of the current
24 * request is returned.
26 * @see \Drupal\Core\EventSubscriber\RedirectResponseSubscriber::checkRedirectUrl()
29 public function getAsArray();
32 * Gets the destination as a path.
34 * To convert to a URL suitable for
35 * \Symfony\Component\HttpFoundation\RedirectResponse::__construct() use
37 * \Drupal\Core\Url::fromUserInput(\Drupal::destination()->get())->setAbsolute()->toString()
42 public function get();
45 * Sets the destination as URL.
47 * This method should be used really rarely, for example views uses it, in
48 * order to override all destination calls in all of its rendering.
50 * @param string $new_destination
51 * The new destination.
55 public function set($new_destination);