1 | <?php namespace Neomerx\JsonApi\Http; |
||
32 | abstract class Responses implements ResponsesInterface |
||
33 | { |
||
34 | /** Header name that contains format of input data from client */ |
||
35 | const HEADER_CONTENT_TYPE = HeaderInterface::HEADER_CONTENT_TYPE; |
||
36 | |||
37 | /** Header name that location of newly created resource */ |
||
38 | const HEADER_LOCATION = HeaderInterface::HEADER_LOCATION; |
||
39 | |||
40 | /** |
||
41 | * Create HTTP response. |
||
42 | * |
||
43 | * @param string|null $content |
||
44 | * @param int $statusCode |
||
45 | * @param array $headers |
||
46 | * |
||
47 | * @return mixed |
||
48 | */ |
||
49 | abstract protected function createResponse($content, $statusCode, array $headers); |
||
50 | |||
51 | /** |
||
52 | * @return EncoderInterface |
||
53 | */ |
||
54 | abstract protected function getEncoder(); |
||
55 | |||
56 | /** |
||
57 | * @return string|null |
||
58 | */ |
||
59 | abstract protected function getUrlPrefix(); |
||
60 | |||
61 | /** |
||
62 | * @return EncodingParametersInterface|null |
||
63 | */ |
||
64 | abstract protected function getEncodingParameters(); |
||
65 | |||
66 | /** |
||
67 | * @return ContainerInterface |
||
68 | */ |
||
69 | abstract protected function getSchemaContainer(); |
||
70 | |||
71 | /** |
||
72 | * @return SupportedExtensionsInterface|null |
||
73 | */ |
||
74 | abstract protected function getSupportedExtensions(); |
||
75 | |||
76 | /** |
||
77 | * @return MediaTypeInterface |
||
78 | */ |
||
79 | abstract protected function getMediaType(); |
||
80 | |||
81 | /** |
||
82 | * @inheritdoc |
||
83 | */ |
||
84 | 1 | public function getContentResponse($data, $statusCode = self::HTTP_OK, $links = null, $meta = null) |
|
93 | |||
94 | /** |
||
95 | * @inheritdoc |
||
96 | */ |
||
97 | 1 | public function getCreatedResponse($resource, $links = null, $meta = null) |
|
107 | |||
108 | /** |
||
109 | * @inheritdoc |
||
110 | */ |
||
111 | 4 | public function getCodeResponse($statusCode) |
|
115 | |||
116 | /** |
||
117 | * @inheritdoc |
||
118 | */ |
||
119 | 1 | public function getMetaResponse($meta, $statusCode = self::HTTP_OK) |
|
126 | |||
127 | /** |
||
128 | * @inheritdoc |
||
129 | */ |
||
130 | 3 | public function getErrorResponse($errors, $statusCode = self::HTTP_BAD_REQUEST) |
|
142 | |||
143 | /** |
||
144 | * @param mixed $resource |
||
145 | * |
||
146 | * @return string |
||
147 | */ |
||
148 | 1 | protected function getResourceLocationUrl($resource) |
|
156 | |||
157 | /** |
||
158 | * @param string|null $content |
||
159 | * @param int $statusCode |
||
160 | * @param array $headers |
||
161 | * |
||
162 | * @return mixed |
||
163 | */ |
||
164 | 10 | protected function createJsonApiResponse($content, $statusCode, array $headers = []) |
|
188 | } |
||
189 |