You are here

public function Response::__construct in Zircon Profile 8.0

Same name in this branch
  1. 8.0 vendor/symfony/http-foundation/Response.php \Symfony\Component\HttpFoundation\Response::__construct()
  2. 8.0 vendor/symfony/browser-kit/Response.php \Symfony\Component\BrowserKit\Response::__construct()
  3. 8.0 vendor/zendframework/zend-diactoros/src/Response.php \Zend\Diactoros\Response::__construct()
  4. 8.0 vendor/guzzlehttp/psr7/src/Response.php \GuzzleHttp\Psr7\Response::__construct()
  5. 8.0 vendor/jcalderonzumba/gastonjs/src/NetworkTraffic/Response.php \Zumba\GastonJS\NetworkTraffic\Response::__construct()
  6. 8.0 vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Response.php \Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\Response::__construct()
Same name and namespace in other branches
  1. 8 vendor/symfony/http-foundation/Response.php \Symfony\Component\HttpFoundation\Response::__construct()

Constructor.

Parameters

mixed $content The response content, see setContent():

int $status The response status code:

array $headers An array of response headers:

Throws

\InvalidArgumentException When the HTTP status code is not valid

6 calls to Response::__construct()
BinaryFileResponse::__construct in vendor/symfony/http-foundation/BinaryFileResponse.php
Constructor.
EnforcedResponse::__construct in core/lib/Drupal/Core/Form/EnforcedResponse.php
Constructs an enforced response.
JsonResponse::__construct in vendor/symfony/http-foundation/JsonResponse.php
Constructor.
RedirectResponse::__construct in vendor/symfony/http-foundation/RedirectResponse.php
Creates a redirect response so that it conforms to the rules defined for a redirect status code.
ResourceResponse::__construct in core/modules/rest/src/ResourceResponse.php
Constructor for ResourceResponse objects.

... See full list

6 methods override Response::__construct()
BinaryFileResponse::__construct in vendor/symfony/http-foundation/BinaryFileResponse.php
Constructor.
EnforcedResponse::__construct in core/lib/Drupal/Core/Form/EnforcedResponse.php
Constructs an enforced response.
JsonResponse::__construct in vendor/symfony/http-foundation/JsonResponse.php
Constructor.
RedirectResponse::__construct in vendor/symfony/http-foundation/RedirectResponse.php
Creates a redirect response so that it conforms to the rules defined for a redirect status code.
ResourceResponse::__construct in core/modules/rest/src/ResourceResponse.php
Constructor for ResourceResponse objects.

... See full list

File

vendor/symfony/http-foundation/Response.php, line 195

Class

Response
Response represents an HTTP response.

Namespace

Symfony\Component\HttpFoundation

Code

public function __construct($content = '', $status = 200, $headers = array()) {
  $this->headers = new ResponseHeaderBag($headers);
  $this
    ->setContent($content);
  $this
    ->setStatusCode($status);
  $this
    ->setProtocolVersion('1.0');
  if (!$this->headers
    ->has('Date')) {
    $this
      ->setDate(\DateTime::createFromFormat('U', time(), new \DateTimeZone('UTC')));
  }
}