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/zendframework/zend-diactoros/src/Response/RedirectResponse.php \Zend\Diactoros\Response\RedirectResponse::__construct()

Create a redirect response.

Produces a redirect response with a Location header and the given status (302 by default).

Note: this method overwrites the `location` $headers value.

Parameters

string|UriInterface $uri URI for the Location header.:

int $status Integer status code for the redirect; 302 by default.:

array $headers Array of headers to use at initialization.:

Overrides Response::__construct

File

vendor/zendframework/zend-diactoros/src/Response/RedirectResponse.php, line 34

Class

RedirectResponse
Produce a redirect response.

Namespace

Zend\Diactoros\Response

Code

public function __construct($uri, $status = 302, array $headers = []) {
  if (!is_string($uri) && !$uri instanceof UriInterface) {
    throw new InvalidArgumentException(sprintf('Uri provided to %s MUST be a string or Psr\\Http\\Message\\UriInterface instance; received "%s"', __CLASS__, is_object($uri) ? get_class($uri) : gettype($uri)));
  }
  $headers['location'] = [
    (string) $uri,
  ];
  parent::__construct('php://temp', $status, $headers);
}