public function SecuredRedirectResponse::setTargetUrl

public SecuredRedirectResponse::setTargetUrl($url)

Sets the redirect target of this response.

Parameters

string $url The URL to redirect to:

Return value

RedirectResponse The current response.

Throws

\InvalidArgumentException

Overrides RedirectResponse::setTargetUrl

File

core/lib/Drupal/Component/HttpFoundation/SecuredRedirectResponse.php, line 54

Class

SecuredRedirectResponse
Provides a common base class for safe redirects.

Namespace

Drupal\Component\HttpFoundation

Code

public function setTargetUrl($url) {
  if (!$this->isSafe($url)) {
    throw new \InvalidArgumentException(sprintf('It is not safe to redirect to %s', $url));
  }
  return parent::setTargetUrl($url);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Component!HttpFoundation!SecuredRedirectResponse.php/function/SecuredRedirectResponse::setTargetUrl/8.1.x