public function Response::setContent in RESTful 7.2
Sets the response content.
Valid types are strings, numbers, NULL, and objects that implement a __toString() method.
Parameters
mixed $content Content that can be cast to string:
Throws
Overrides ResponseInterface::setContent
2 calls to Response::setContent()
- Response::prepare in src/
Http/ Response.php - Prepares the Response before it is sent to the client.
- Response::__construct in src/
Http/ Response.php - Constructor.
File
- src/
Http/ Response.php, line 257 - Contains \Drupal\restful\Http\Response.
Class
Namespace
Drupal\restful\HttpCode
public function setContent($content) {
if ($content !== NULL && !is_string($content) && !is_numeric($content) && !is_callable(array(
$content,
'__toString',
))) {
throw new InternalServerErrorException(sprintf('The Response content must be a string or object implementing __toString(), "%s" given.', gettype($content)));
}
$this->content = (string) $content;
}