本文整理匯總了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);
}
}