function HtmlResponse::__construct

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Render/HtmlResponse.php \Drupal\Core\Render\HtmlResponse::__construct()
  2. 11.x core/lib/Drupal/Core/Render/HtmlResponse.php \Drupal\Core\Render\HtmlResponse::__construct()

Constructs a HtmlResponse object.

Parameters

array|string $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.

1 call to HtmlResponse::__construct()
BigPipeResponse::__construct in core/modules/big_pipe/src/Render/BigPipeResponse.php
Constructs a new BigPipeResponse.
1 method overrides HtmlResponse::__construct()
BigPipeResponse::__construct in core/modules/big_pipe/src/Render/BigPipeResponse.php
Constructs a new BigPipeResponse.

File

core/lib/Drupal/Core/Render/HtmlResponse.php, line 41

Class

HtmlResponse
Response that contains and can expose cacheability metadata and attachments.

Namespace

Drupal\Core\Render

Code

public function __construct($content = '', int $status = 200, array $headers = []) {
    parent::__construct('', $status, $headers);
    $this->setContent($content);
}

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