function SecuredRedirectResponse::setTargetUrl

Same name in other branches
  1. 9 core/lib/Drupal/Component/HttpFoundation/SecuredRedirectResponse.php \Drupal\Component\HttpFoundation\SecuredRedirectResponse::setTargetUrl()
  2. 8.9.x core/lib/Drupal/Component/HttpFoundation/SecuredRedirectResponse.php \Drupal\Component\HttpFoundation\SecuredRedirectResponse::setTargetUrl()
  3. 11.x core/lib/Drupal/Component/HttpFoundation/SecuredRedirectResponse.php \Drupal\Component\HttpFoundation\SecuredRedirectResponse::setTargetUrl()
1 call to SecuredRedirectResponse::setTargetUrl()
TrustedRedirectResponse::setTrustedTargetUrl in core/lib/Drupal/Core/Routing/TrustedRedirectResponse.php
Sets the target URL to a trusted URL.

File

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

Class

SecuredRedirectResponse
Provides a common base class for safe redirects.

Namespace

Drupal\Component\HttpFoundation

Code

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

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