本文整理汇总了PHP中Phalcon\Http\Response::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::__construct方法的具体用法?PHP Response::__construct怎么用?PHP Response::__construct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phalcon\Http\Response
的用法示例。
在下文中一共展示了Response::__construct方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
parent::__construct();
parent::setHeader('Access-Control-Allow-Origin', '*');
parent::setHeader('Access-Control-Allow-Headers', 'X-Requested-With');
$this->setStatusCode(self::DEFAULT_STATUS_CODE);
}
示例2: __construct
public function __construct(Response $response)
{
parent::__construct();
$this->setStatusCode($response->getStatusCode(), $response->getStatusMessage());
$this->data = $response->getData();
$this->meta = $response->getMeta();
$this->messages = $response->getMessages();
}
示例3: __construct
/**
* @param ResponsePayload $body
* @param int|null $code
* @param string|null $status
*/
public function __construct(ResponsePayload $body, $code = null, $status = null)
{
parent::__construct(null, $code, $status);
$this->setContentType('application/json');
$this->setHeader('Access-Control-Allow-Origin', '*');
$this->setHeader('Access-Control-Allow-Methods', 'GET,HEAD,PUT,PATCH,POST,DELETE');
$this->setHeader('Access-Control-Allow-Headers', 'Content-Type, X-Requested-With, Authorization');
$this->setJsonContent($body);
}
示例4: __construct
/**
* @param Response $controllerResponse
*/
public function __construct($controllerResponse)
{
if ($controllerResponse instanceof ResponseArray) {
foreach ($controllerResponse->getResponses() as $response) {
$this->records[] = $response->getData();
}
} elseif ($controllerResponse instanceof Response) {
$this->records[] = $controllerResponse->getData();
}
parent::__construct();
}
示例5: __construct
/**
* PHPWebDevelopers\Api\Common\Http\Response constructor
*
* @param string $content
* @param int $code
* @param string $status
*/
public function __construct($content = null, $code = null, $status = null)
{
parent::__construct($content, $code, $status);
$request = new PhalconRequest();
//@TODO Security fail!! Please do not go with this BETA
$origin = $request->getHeader("ORIGIN");
if (!empty($origin)) {
parent::setHeader("Access-Control-Allow-Origin", $origin);
}
parent::setContentType(self::CONTENT_TYPE_JSON, self::CHARSET);
parent::setHeader("Access-Control-Allow-Methods", self::ALLOW_METHODS);
parent::setHeader("Access-Control-Allow-Headers", self::ALLOW_HEADERS);
parent::setHeader("Access-Control-Allow-Credentials", self::ALLOW_CREDENTIALS);
}
示例6: __construct
public function __construct($content = null)
{
parent::__construct();
$this->setContentType('application/json', 'UTF-8');
$this->setContent($content);
}
示例7: __construct
public function __construct($content = null, $code = null, $status = null)
{
parent::__construct();
$this->setJsonContent($content);
}
示例8: __construct
public function __construct($content = null, $code = null, $status = null)
{
parent::__construct($content, $code, $status);
$this->setHeader('Content-Type', 'application/json');
}
示例9: __construct
public function __construct()
{
parent::__construct();
$this->errorMessages = ErrorMessages::$messages;
}
示例10: __construct
public function __construct($content = null, $code = null, $status = null)
{
parent::__construct($content, $code, $status);
$this->setContentType("application/json", "UTF-8");
}
示例11: __construct
/**
* @param Template|string|null $content
* @param int|null $code
* @param array $headers
*/
public function __construct($content = null, $code = null, $headers = [])
{
parent::__construct();
if ($content) {
$this->setContent($content);
}
if ($code) {
$this->setStatusCode($code);
}
foreach (array_merge(static::$defaultHeaders, $headers) as $name => $value) {
$this->setHeader($name, $value);
}
}