1 | <?php |
||
17 | class FormattedResponder extends SortedDictionary implements ResponderInterface |
||
18 | { |
||
19 | use ResolverTrait; |
||
20 | |||
21 | /** |
||
22 | * @var Negotiator |
||
23 | */ |
||
24 | private $negotiator; |
||
25 | |||
26 | /** |
||
27 | * @param Negotiator $negotiator |
||
28 | * @param ResolverInterface $resolver |
||
29 | */ |
||
30 | 10 | public function __construct( |
|
42 | |||
43 | /** |
||
44 | * @inheritDoc |
||
45 | */ |
||
46 | 5 | public function __invoke( |
|
57 | |||
58 | /** |
||
59 | * Determine if the payload has usable output |
||
60 | * |
||
61 | * @param PayloadInterface $payload |
||
62 | * |
||
63 | * @return boolean |
||
64 | */ |
||
65 | 5 | protected function hasOutput(PayloadInterface $payload) |
|
69 | |||
70 | /** |
||
71 | * Retrieve a map of accepted priorities with the responsible formatter. |
||
72 | * |
||
73 | * @return array |
||
74 | */ |
||
75 | 2 | protected function priorities() |
|
87 | |||
88 | /** |
||
89 | * Retrieve the formatter to use for the current request. |
||
90 | * |
||
91 | * Uses content negotiation to find the best available output format for |
||
92 | * the requested content type. |
||
93 | * |
||
94 | * @param ServerRequestInterface $request |
||
95 | * |
||
96 | * @return FormatterInterface |
||
97 | */ |
||
98 | 2 | protected function formatter(ServerRequestInterface $request) |
|
115 | |||
116 | /** |
||
117 | * Update the response by formatting the payload. |
||
118 | * |
||
119 | * @param ServerRequestInterface $request |
||
120 | * @param ResponseInterface $response |
||
121 | * @param PayloadInterface $payload |
||
122 | * |
||
123 | * @return ResponseInterface |
||
124 | */ |
||
125 | 2 | protected function format( |
|
138 | |||
139 | /** |
||
140 | * @inheritDoc |
||
141 | * |
||
142 | * @throws FormatterException |
||
143 | * If $classes does not implement the correct interface, |
||
144 | * or does not have a quality value. |
||
145 | */ |
||
146 | 10 | protected function assertValid(array $classes) |
|
160 | |||
161 | /** |
||
162 | * @inheritDoc |
||
163 | */ |
||
164 | 3 | protected function sortValues() |
|
168 | } |
||
169 |