You are here

public function RedirectResponse::__construct in Zircon Profile 8.0

Same name in this branch
  1. 8.0 vendor/symfony/http-foundation/RedirectResponse.php \Symfony\Component\HttpFoundation\RedirectResponse::__construct()
  2. 8.0 vendor/zendframework/zend-diactoros/src/Response/RedirectResponse.php \Zend\Diactoros\Response\RedirectResponse::__construct()
Same name and namespace in other branches
  1. 8 vendor/symfony/http-foundation/RedirectResponse.php \Symfony\Component\HttpFoundation\RedirectResponse::__construct()

Creates a redirect response so that it conforms to the rules defined for a redirect status code.

Parameters

string $url The URL to redirect to:

int $status The status code (302 by default):

array $headers The headers (Location is always set to the given URL):

Throws

\InvalidArgumentException

Overrides Response::__construct

See also

http://tools.ietf.org/html/rfc2616#section-10.3

1 call to RedirectResponse::__construct()
TrustedRedirectResponse::__construct in core/lib/Drupal/Core/Routing/TrustedRedirectResponse.php
Creates a redirect response so that it conforms to the rules defined for a redirect status code.
1 method overrides RedirectResponse::__construct()
TrustedRedirectResponse::__construct in core/lib/Drupal/Core/Routing/TrustedRedirectResponse.php
Creates a redirect response so that it conforms to the rules defined for a redirect status code.

File

vendor/symfony/http-foundation/RedirectResponse.php, line 34

Class

RedirectResponse
RedirectResponse represents an HTTP response doing a redirect.

Namespace

Symfony\Component\HttpFoundation

Code

public function __construct($url, $status = 302, $headers = array()) {
  if (empty($url)) {
    throw new \InvalidArgumentException('Cannot redirect to an empty URL.');
  }
  parent::__construct('', $status, $headers);
  $this
    ->setTargetUrl($url);
  if (!$this
    ->isRedirect()) {
    throw new \InvalidArgumentException(sprintf('The HTTP status code is not a redirect ("%s" given).', $status));
  }
}