Example #1
1
 public function __construct($data = null, $status = 200, $headers = array(), $options = 0)
 {
     parent::__construct($data, $status, $headers, $options);
     if ($data != null) {
         $this->data($data);
     }
 }
Example #2
0
 public function __construct($data = null, $status = 200, $headers = array(), $options = 0)
 {
     if ($data instanceof \Exception) {
         $data = array("code" => $data->getCode(), "error" => $data->getMessage());
     } else {
         // move the prepare function here
         Carbon::setToStringFormat('Y-m-d\\TH:i:s.z\\Z');
         $data = ParseHelper::prepareResponse($data);
     }
     parent::__construct($data, $status, $headers, $options);
 }
 /**
  * Constructor.
  *
  * @param int                           $httpStatusCode   HTTP status code
  * @param mixed                         $errorCode        Internal error code
  * @param string                        $errorTitle       Error description
  * @param Illuminate\Support\MessageBag $errors           Validation errors
  */
 public function __construct($httpStatusCode, $errorCode, $errorTitle, ValidationMessages $errors = NULL)
 {
     $data = ['errors' => []];
     if ($errors) {
         foreach ($errors->keys() as $field) {
             foreach ($errors->get($field) as $message) {
                 $data['errors'][] = ['status' => $httpStatusCode, 'code' => $errorCode, 'title' => 'Validation Fail', 'detail' => $message, 'meta' => ['field' => $field]];
             }
         }
     }
     parent::__construct($data, $httpStatusCode);
 }
 public function __construct($document = null, $request = null, $status = 200, $headers = [], $options = 0)
 {
     if (!$request instanceof Request) {
         throw new \InvalidArgumentException(sprintf('Request is not an instance of %s', Request::class));
     }
     if ($document === null) {
         $document = new Document();
     } elseif (!$document instanceof Document) {
         throw new \InvalidArgumentException(sprintf('Document is not an instance of %s', Document::class));
     }
     $headers = array_merge(['Content-Type' => self::MIME_TYPE], self::$defaultHeaders, $headers);
     $this->applyPreferHeader($document, $request, $headers, $options);
     $document->sort(self::$defaultSorting, self::$controlsSorting, self::$metaSorting);
     parent::__construct($document, $status, $headers, $options);
     $this->applyEtag($request);
 }
Example #5
0
 public function __construct($schema = null, $request = null, $status = 200, $headers = [], $options = 0)
 {
     if (!$request instanceof Request) {
         throw new \InvalidArgumentException(sprintf('Request is not an instance of %s', Request::class));
     }
     if ($schema === null) {
         $schema = new JsonSchema();
     } elseif (!$schema instanceof JsonSchema) {
         throw new \InvalidArgumentException(sprintf('Document is not an instance of %s', JsonSchema::class));
     }
     $options |= JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT;
     $schema->setSchema('http://json-schema.org/draft-04/schema#');
     $schema->sort(['id', '$schema', 'title', 'description', 'type', 'properties', 'patternProperties', 'required', 'additionalProperties', '{data}', '@meta', '@controls', '@error', '@namespaces']);
     $headers['Content-Type'] = self::MIME_TYPE;
     $headers = array_merge($headers, self::$defaultHeaders);
     parent::__construct($schema, $status, $headers, $options);
     $this->applyEtag($request);
 }
 /**
  * Constructor.
  *
  * @param int    $httpStatusCode HTTP status code
  * @param mixed  $errorCode      Internal error code
  * @param string $errorTitle     Error description
  */
 public function __construct($httpStatusCode, $errorCode, $errorTitle, array $additionalAttrs = array())
 {
     $data = ['errors' => [array_merge(['status' => $httpStatusCode, 'code' => $errorCode, 'title' => $errorTitle], $additionalAttrs)]];
     parent::__construct($data, $httpStatusCode);
 }
Example #7
0
 /**
  * @param null  $data
  * @param int   $status
  * @param array $headers
  * @param int   $options
  */
 public function __construct($data = null, $status = 200, $headers = [], $options = 0)
 {
     parent::__construct($data, $status, $headers, $options);
 }
Example #8
0
 public function __construct($data, $status = true)
 {
     $this->myreturn = ['status' => $status ? 'success' : 'failure', 'data' => $data];
     parent::__construct($this->myreturn, $status ? 200 : 422);
 }
 /**
  * Constructor.
  * Triggers compilation of additional information when constructed.
  *
  * @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 = array())
 {
     $this->buildSiblingContent();
     return parent::__construct($data, $status, $headers);
 }
Example #10
0
 public function __construct($data, $status, array $headers, $options)
 {
     parent::__construct($data, $status, $headers, $options);
 }
Example #11
0
 public function __construct($parcel = null)
 {
     parent::__construct();
     $this->setParcel($parcel);
 }
Example #12
0
 public function __construct($content = '', $status = self::HTTP_OK, array $headers = [], $options = 0)
 {
     //        $headers['Access-Control-Allow-Origin'] = '*';
     //        $headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, DELETE, OPTIONS';
     parent::__construct($content, $status, $headers, $options);
 }