Advertisement
dimuska139

Untitled

Oct 4th, 2021
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.05 KB | None | 0 0
  1. class ApiResponse extends JsonResponse
  2. {
  3.     /**
  4.      * @OA\Property(description="Данные", type="object")
  5.      */
  6.     public $data;
  7.  
  8.     /**
  9.      * @OA\Property(
  10.      *     property="meta",
  11.      *     type="object",
  12.      *     description="Разная опциональная дополнительная информация"
  13.      * )
  14.      */
  15.     public $meta;
  16.  
  17.     /**
  18.      * @OA\Property(description="Список ошибок", type="object")
  19.      * @var object | null
  20.      */
  21.     public $errors;
  22.  
  23.     /**
  24.      *
  25.      * @param null $data
  26.      * @param null $meta
  27.      * @param null $errors
  28.      * @param int $status
  29.      * @param array $headers
  30.      */
  31.     public function __construct($data = null, $meta = null, $errors = null, int $status = 200, array $headers = [])
  32.     {
  33.         $data = [
  34.             'data' => $data,
  35.             'meta' => $meta,
  36.             'errors' => $errors
  37.         ];
  38.         parent::__construct($data, $status, $headers, false);
  39.         $this->setEncodingOptions(JSON_UNESCAPED_UNICODE);
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement