1 | <?php namespace Neomerx\JsonApi\Http; |
||
31 | abstract class BaseResponses implements ResponsesInterface |
||
32 | { |
||
33 | /** Header name that contains format of input data from client */ |
||
34 | const HEADER_CONTENT_TYPE = HeaderParametersParserInterface::HEADER_CONTENT_TYPE; |
||
35 | |||
36 | /** Header name that location of newly created resource */ |
||
37 | const HEADER_LOCATION = 'Location'; |
||
38 | |||
39 | /** |
||
40 | * Create HTTP response. |
||
41 | * |
||
42 | * @param string|null $content |
||
43 | * @param int $statusCode |
||
44 | * @param array $headers |
||
45 | * |
||
46 | * @return mixed |
||
47 | */ |
||
48 | abstract protected function createResponse(?string $content, int $statusCode, array $headers); |
||
49 | |||
50 | /** |
||
51 | * @return EncoderInterface |
||
52 | */ |
||
53 | abstract protected function getEncoder(): EncoderInterface; |
||
54 | |||
55 | /** |
||
56 | * @return string|null |
||
57 | */ |
||
58 | abstract protected function getUrlPrefix(): ?string; |
||
59 | |||
60 | /** |
||
61 | * @return EncodingParametersInterface|null |
||
62 | */ |
||
63 | abstract protected function getEncodingParameters(): ?EncodingParametersInterface; |
||
64 | |||
65 | /** |
||
66 | * @return ContainerInterface |
||
67 | */ |
||
68 | abstract protected function getSchemaContainer(): ?ContainerInterface; |
||
69 | |||
70 | /** |
||
71 | * @return MediaTypeInterface |
||
72 | */ |
||
73 | abstract protected function getMediaType(): MediaTypeInterface; |
||
74 | |||
75 | /** |
||
76 | * @inheritdoc |
||
77 | */ |
||
78 | 2 | public function getContentResponse( |
|
92 | |||
93 | /** |
||
94 | * @inheritdoc |
||
95 | */ |
||
96 | 2 | public function getCreatedResponse($resource, array $links = null, $meta = null, array $headers = []) |
|
106 | |||
107 | /** |
||
108 | * @inheritdoc |
||
109 | */ |
||
110 | 1 | public function getCodeResponse(int $statusCode, array $headers = []) |
|
114 | |||
115 | /** |
||
116 | * @inheritdoc |
||
117 | */ |
||
118 | 2 | public function getMetaResponse($meta, int $statusCode = self::HTTP_OK, array $headers = []) |
|
125 | |||
126 | /** |
||
127 | * @inheritDoc |
||
128 | */ |
||
129 | 2 | public function getIdentifiersResponse( |
|
143 | |||
144 | /** |
||
145 | * @inheritdoc |
||
146 | * |
||
147 | * @SuppressWarnings(PHPMD.ElseExpression) |
||
148 | */ |
||
149 | 4 | public function getErrorResponse($errors, int $statusCode = self::HTTP_BAD_REQUEST, array $headers = []) |
|
161 | |||
162 | /** |
||
163 | * @param mixed $resource |
||
164 | * |
||
165 | * @return string |
||
166 | */ |
||
167 | 2 | protected function getResourceLocationUrl($resource): string |
|
175 | |||
176 | /** |
||
177 | * @param string|null $content |
||
178 | * @param int $statusCode |
||
179 | * @param array $headers |
||
180 | * @param bool $addContentType |
||
181 | * |
||
182 | * @return mixed |
||
183 | * |
||
184 | * @SuppressWarnings(PHPMD.BooleanArgumentFlag) |
||
185 | */ |
||
186 | 13 | protected function createJsonApiResponse( |
|
198 | } |
||
199 |