You are here

class RedirectResponse in Zircon Profile 8

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

Produce a redirect response.

Hierarchy

Expanded class hierarchy of RedirectResponse

File

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

Namespace

Zend\Diactoros\Response
View source
class RedirectResponse extends Response {

  /**
   * 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.
   *
   * @param string|UriInterface $uri URI for the Location header.
   * @param int $status Integer status code for the redirect; 302 by default.
   * @param array $headers Array of headers to use at initialization.
   */
  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);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MessageTrait::$headerNames protected property Map of normalized header name to original name used to register header.
MessageTrait::$headers protected property List of all registered headers, as key => array of values.
MessageTrait::$protocol private property
MessageTrait::$stream private property
MessageTrait::arrayContainsOnlyStrings private function Test that an array contains only strings
MessageTrait::assertValidHeaderValue private static function Assert that the provided header values are valid.
MessageTrait::filterHeaders private function Filter a set of headers to ensure they are in the correct internal format.
MessageTrait::filterStringValue private static function Test if a value is a string
MessageTrait::getBody public function Gets the body of the message.
MessageTrait::getHeader public function Retrieves a message header value by the given case-insensitive name. 1
MessageTrait::getHeaderLine public function Retrieves a comma-separated string of the values for a single header.
MessageTrait::getHeaders public function Retrieves all message headers. 1
MessageTrait::getProtocolVersion public function Retrieves the HTTP protocol version as a string.
MessageTrait::hasHeader public function Checks if a header exists by the given case-insensitive name.
MessageTrait::withAddedHeader public function Return an instance with the specified header appended with the given value.
MessageTrait::withBody public function Return an instance with the specified message body.
MessageTrait::withHeader public function Return an instance with the provided header, replacing any existing values of any headers with the same case-insensitive name.
MessageTrait::withoutHeader public function Return an instance without the specified header.
MessageTrait::withProtocolVersion public function Return an instance with the specified HTTP protocol version.
RedirectResponse::__construct public function Create a redirect response. Overrides Response::__construct
Response::$phrases private property Map of standard HTTP status code/reason phrases
Response::$reasonPhrase private property
Response::$statusCode private property
Response::assertHeaders private function Ensure header names and values are valid.
Response::getReasonPhrase public function Gets the response reason phrase associated with the status code. Overrides ResponseInterface::getReasonPhrase
Response::getStatusCode public function Gets the response status code. Overrides ResponseInterface::getStatusCode
Response::validateStatus private function Validate a status code.
Response::withStatus public function Return an instance with the specified status code and, optionally, reason phrase. Overrides ResponseInterface::withStatus