1 | <?php |
||
8 | class JsonApiResponse extends JsonResponse |
||
9 | { |
||
10 | /** |
||
11 | * @var integer |
||
12 | */ |
||
13 | private $code; |
||
14 | |||
15 | /** |
||
16 | * @var string |
||
17 | */ |
||
18 | private $charset; |
||
19 | |||
20 | /** |
||
21 | * Create JsonApiResponse |
||
22 | * This class only wrap JsonResponse from Nette and add possibility |
||
23 | * to setup response code and automaticaly set content type |
||
24 | * |
||
25 | * @param integer $code |
||
26 | * @param mixed $data |
||
27 | * @param string $contentType |
||
28 | * @param string $charset |
||
29 | */ |
||
30 | 18 | public function __construct($code, $data, $contentType = 'application/json', $charset = 'utf-8') |
|
36 | |||
37 | /** |
||
38 | * Return api response http code |
||
39 | * |
||
40 | * @return integer |
||
41 | */ |
||
42 | 18 | public function getCode() |
|
46 | |||
47 | /** |
||
48 | * Return encoding charset for http response |
||
49 | * |
||
50 | * @return string |
||
51 | */ |
||
52 | 6 | public function getCharset() |
|
56 | |||
57 | /** |
||
58 | * Sends response to output. |
||
59 | * @return void |
||
60 | */ |
||
61 | 3 | public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse) |
|
69 | } |
||
70 |