本文整理汇总了PHP中SS_HTTPResponse::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP SS_HTTPResponse::__construct方法的具体用法?PHP SS_HTTPResponse::__construct怎么用?PHP SS_HTTPResponse::__construct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SS_HTTPResponse
的用法示例。
在下文中一共展示了SS_HTTPResponse::__construct方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Create a new HTTP response
*
* @param SS_HTTPRequest $request - The corresponding request object
* @param string $body - The body of the response
* @param int $statusCode - The numeric status code - 200, 404, etc
* @param string $statusDescription - The text to be given alongside the status code.
* See {@link setStatusCode()} for more information.
*/
public function __construct($request = null, $body = null, $statusCode = null, $statusDescription = null)
{
if ($request && $request instanceof SS_HTTPRequest) {
$this->request = $request;
} elseif (is_string($request)) {
// respond intelligently if someone uses the parent constructor syntax
$statusDescription = $statusCode;
$statusCode = $body;
$body = $request;
}
parent::__construct($body, $statusCode, $statusDescription);
// default content type
$this->addHeader('Content-type', 'application/json');
$this->addRenderContext('DEFAULT', Controller::curr());
}
示例2: __construct
public function __construct(GridField $gridField)
{
$this->gridField = $gridField;
parent::__construct('', 500);
}