当前位置: 首页>>代码示例>>PHP>>正文


PHP JsonResponse::__construct方法代码示例

本文整理汇总了PHP中Symfony\Component\HttpFoundation\JsonResponse::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP JsonResponse::__construct方法的具体用法?PHP JsonResponse::__construct怎么用?PHP JsonResponse::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\HttpFoundation\JsonResponse的用法示例。


在下文中一共展示了JsonResponse::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Construct the basic instance properties.
  *
  * @param mixed|null  $content              The response content {@see setFinalContent()}
  * @param int|null    $status               Status for this response.
  * @param array       $headers              Headers specific to this response.
  * @param array       $headersGlobal        The global headers configured.
  * @param array       $headersTypeSpecific  The type-specific headers configured.
  * @param string|null $charsetGlobal        The global charset configured.
  * @param string|null $charsetTypeSpecific  The type-specific charset configured.
  * @param float|null  $protocolGlobal       The global charset configured.
  * @param float|null  $protocolTypeSpecific The type-specific charset configured.
  *
  * @throws \InvalidArgumentException When the HTTP status code is not valid
  *
  * @api
  */
 public function __construct($content = null, $status = null, $headers = [], $headersGlobal = [], $headersTypeSpecific = [], $charsetGlobal = null, $charsetTypeSpecific = null, $protocolGlobal = null, $protocolTypeSpecific = null)
 {
     parent::__construct(null, $this->getFinalStatus($status), $this->getFinalHeaders($headersGlobal, $headersTypeSpecific, $headers));
     $this->setData($this->getFinalContent($content));
     $this->setCharset($this->getFinalCharset($charsetGlobal, $charsetTypeSpecific));
     $this->setProtocolVersion($this->getFinalProtocol($protocolGlobal, $protocolTypeSpecific));
 }
开发者ID:scr-be,项目名称:mantle-bundle,代码行数:24,代码来源:JsonResponse.php

示例2: __construct

 /**
  * @see SymfonyHttpResponse::__construct
  */
 public function __construct($data = NULL, $status = 200, $headers = [])
 {
     parent::__construct($data, $status, $headers);
     $this->headers->set('Content-Type', JsonApiSpec::HATEOAS_CONTENT_TYPE);
     // Keeps the data NULL if NULL it is.
     $this->setData($data);
 }
开发者ID:mb3rnard,项目名称:hateoas-bundle,代码行数:10,代码来源:JsonResponse.php

示例3: __construct

 /**
  * @param Response|null $response
  * @param int                   $status
  * @param array                 $headers
  */
 public function __construct(Response $response = null, $status = 200, $headers = array())
 {
     parent::__construct(null, $status, $headers);
     if ($response !== null) {
         $this->setResponse($response);
     }
 }
开发者ID:teqneers,项目名称:ext-direct,代码行数:12,代码来源:UploadResponse.php

示例4: __construct

 /**
  * @param type $errorMessage
  * @param type $errorCode
  * @param type $status
  */
 public function __construct($errorMessage, $errorCode = 0, $status = HTTPCode::OK)
 {
     $data['success'] = false;
     $data['errorMessage'] = $errorMessage;
     $data['errorCode'] = $errorCode;
     return parent::__construct($data, $status);
 }
开发者ID:redefinelab,项目名称:silexresponse,代码行数:12,代码来源:JsonErrorResponse.php

示例5: __construct

 /**
  * Constructor
  *
  * @param array $data
  * @param int $code
  * @param array $headers
  *
  * @return self
  */
 public function __construct(array $data = [], $code = 200, array $headers = [])
 {
     $data = [self::KEY_DATA => $data];
     parent::__construct($data, $code, $headers);
     $this->pristineData = $data;
     $this->resolveData();
     return $this;
 }
开发者ID:epfremmer,项目名称:swagger-behat-demo,代码行数:17,代码来源:JsonResponse.php

示例6: __construct

 /**
  * Constructor.
  *
  * @param mixed $data The response data
  * @param int $status The response status code
  * @param array $headers An array of response headers
  */
 public function __construct($data = null, $status = 200, $headers = [])
 {
     parent::__construct('', $status, $headers);
     if (null === $data) {
         $data = new \ArrayObject();
     }
     $this->setContent($data);
 }
开发者ID:mediamonks,项目名称:symfony-rest-api-bundle,代码行数:15,代码来源:JsonResponse.php

示例7: __construct

 public function __construct($data = array(), $successMessage = null, $status = HTTPCode::OK)
 {
     $data['success'] = true;
     if ($successMessage) {
         $data['successMessage'] = $successMessage;
     }
     return parent::__construct($data, $status);
 }
开发者ID:redefinelab,项目名称:silexresponse,代码行数:8,代码来源:JsonSuccessResponse.php

示例8: __construct

 public function __construct($data = null, $status = 200, $headers = array())
 {
     if (null === $data) {
         $data = new \stdClass();
     }
     parent::__construct($data, $status, $headers);
     $this->rawData = $data;
 }
开发者ID:mat33470,项目名称:PFA,代码行数:8,代码来源:JsonResponse.php

示例9: __construct

 public function __construct(ApiProblem $problem, $status = 200, $headers = array())
 {
     $headers += ['Content-Type' => 'application/problem+json'];
     if (null !== $problem->getStatus()) {
         $headers += ['X-Status-Code' => $problem->getStatus()];
     }
     $data = $problem->asArray();
     parent::__construct($data, $status, $headers);
 }
开发者ID:Axxon,项目名称:udb3-silex,代码行数:9,代码来源:ApiProblemJsonResponse.php

示例10: __construct

 /**
  * @param string $message
  * @param int    $status
  * @param null   $logref
  * @param array  $headers
  */
 public function __construct($message, $status = self::DEFAULT_STATUS, $logref = null, $headers = [])
 {
     $data = ['message' => $message];
     if (null !== $logref) {
         $data['logref'] = $logref;
     }
     $headers = array_merge(['Content-Type' => 'application/vnd.error+json'], $headers);
     parent::__construct($data, $status, $headers);
 }
开发者ID:krizon,项目名称:swagger-bundle,代码行数:15,代码来源:VndErrorResponse.php

示例11: __construct

 public function __construct($data, $alias, $route)
 {
     parent::__construct('', 200, array('Content-Type' => sprintf('application/%s+json', $alias), 'Link' => sprintf('<%s>; rel="describedBy"', $route)));
     // Add pretty printing to the default encoding options supplied by
     // symfony's JsonResponse
     if (isset($this->encodingOptions) && defined('JSON_PRETTY_PRINT')) {
         $this->encodingOptions = $this->encodingOptions | JSON_PRETTY_PRINT;
     }
     $this->setData($data);
 }
开发者ID:brayansdt,项目名称:KnpJsonSchemaBundle,代码行数:10,代码来源:JsonSchemaResponse.php

示例12: __construct

 public function __construct($success = FALSE, $data = NULL, $statusCode = 200, array $headers = [])
 {
     $resultData = function ($data, $default = []) {
         return empty($data) ? $default : (array) $data;
     };
     $json['success'] = (bool) $success;
     if (is_array($data) and array_key_exists('result', $data)) {
         $json += $resultData($data);
     } else {
         $json['result'] = $resultData($data);
     }
     parent::__construct($json, (int) $statusCode, $headers);
 }
开发者ID:otar,项目名称:restly-friendly,代码行数:13,代码来源:Response.php

示例13: __construct

 public function __construct(ValidationError $validationErrorException)
 {
     $violations = $validationErrorException->getViolations();
     $errors = [];
     /** @var ConstraintViolationInterface $violation */
     foreach ($violations as $violation) {
         $errors[$violation->getPropertyPath()][] = $violation->getMessage();
     }
     $errors = array_map(function (array $messages) {
         return implode(', ', $messages);
     }, $errors);
     parent::__construct(['message' => 'Validation error', 'errors' => $errors], self::HTTP_BAD_REQUEST);
 }
开发者ID:microservices-playground,项目名称:api-comments,代码行数:13,代码来源:ValidationErrorResponse.php

示例14: __construct

 /**
  * @param mixed      $status
  * @param string     $tokenType
  * @param string     $realm
  * @param mixed|null $data
  */
 public function __construct($status, $tokenType, $realm, $data = null)
 {
     if (is_null($data)) {
         $data = array();
     }
     $defaultData = array('error' => 'access_denied', 'error_description' => 'OAuth2 authentication required');
     $data = array_merge($defaultData, $data);
     $header = sprintf('%s realm=%s', ucwords($tokenType), $realm);
     foreach ($data as $key => $value) {
         $header .= sprintf(', %s=%s', $key, $value);
     }
     $headers = array('WWW-Authenticate' => $header);
     parent::__construct($data, $status, $headers);
 }
开发者ID:atokovoy,项目名称:oauth-security-proxy,代码行数:20,代码来源:ForbiddenResponse.php

示例15: __construct

 /**
  * JsonRpcHttpResponse constructor.
  *
  * @param JsonRpcResponseInterface|JsonRpcResponseInterface[] $jsonRpc
  * @param int                                                 $status
  * @param array                                               $headers
  */
 public function __construct($jsonRpc = null, $status = 200, array $headers = [])
 {
     if (null === $jsonRpc) {
         parent::__construct(null, $status, $headers);
         return;
     }
     if (!is_array($jsonRpc)) {
         parent::__construct($this->formatJsonRpcResponse($jsonRpc), $status, $headers);
         return;
     }
     $data = [];
     foreach ($jsonRpc as $response) {
         $data[] = $this->formatJsonRpcResponse($response);
     }
     parent::__construct($data, $status, $headers);
 }
开发者ID:bankiru,项目名称:jsonrpc-server-bundle,代码行数:23,代码来源:JsonRpcHttpResponse.php


注:本文中的Symfony\Component\HttpFoundation\JsonResponse::__construct方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。