本文整理汇总了PHP中Nette\Http\IResponse::getCode方法的典型用法代码示例。如果您正苦于以下问题:PHP IResponse::getCode方法的具体用法?PHP IResponse::getCode怎么用?PHP IResponse::getCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Http\IResponse
的用法示例。
在下文中一共展示了IResponse::getCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* Send JSONP response to output
* @param IRequest $httpRequest
* @param IResponse $httpResponse
* @throws \Drahak\Restful\InvalidArgumentException
*/
public function send(IRequest $httpRequest, IResponse $httpResponse)
{
$httpResponse->setContentType($this->contentType ? $this->contentType : 'application/javascript', 'UTF-8');
$data = array();
$data['response'] = $this->data;
$data['status'] = $httpResponse->getCode();
$data['headers'] = $httpResponse->getHeaders();
$callback = $httpRequest->getQuery('jsonp') ? Strings::webalize($httpRequest->getQuery('jsonp'), NULL, FALSE) : '';
echo $callback . '(' . $this->mapper->stringify($data, $this->isPrettyPrint()) . ');';
}
示例2: createResponse
/**
* Creates and returns response from given payload formatted for selected
* output content type.
*
* @return Nette\Application\IResponse
*/
protected function createResponse($payload = NULL)
{
if ($this->outputContentType == 'application/json') {
// Don't use JsonResponse because it manages the caching headers
return new Nette\Application\Responses\TextResponse(func_num_args() ? Nette\Utils\Json::encode($payload) : NULL);
} else {
$text = func_num_args() ? (string) Nette\Utils\Html::el('pre', Nette\Utils\Json::encode($payload, Nette\Utils\Json::PRETTY)) : '<span style="font-style: italic;">No data</span>';
$text = '<h1>HTTP ' . $this->httpResponse->getCode() . '</h1>' . $text;
return new Nette\Application\Responses\TextResponse($text);
}
}