1 | <?php |
||
22 | class Render implements HandlerInterface |
||
23 | { |
||
24 | /** |
||
25 | * Known handled content types. |
||
26 | * |
||
27 | * @var array |
||
28 | */ |
||
29 | protected $knownContentTypes = [ |
||
30 | 'application/json', |
||
31 | 'application/xml', |
||
32 | 'text/xml', |
||
33 | 'text/html', |
||
34 | ]; |
||
35 | |||
36 | /** |
||
37 | * {@inheritdoc} |
||
38 | */ |
||
39 | public function __invoke(ServerRequestInterface $request, ResponseInterface $response, Watcher $watcher) |
||
72 | |||
73 | /** |
||
74 | * Render HTML maintenance message. |
||
75 | * |
||
76 | * @param \Janitor\Watcher $watcher |
||
77 | * |
||
78 | * @return string |
||
79 | */ |
||
80 | protected function renderHtml(Watcher $watcher) |
||
95 | |||
96 | /** |
||
97 | * Render JSON maintenance message. |
||
98 | * |
||
99 | * @param \Janitor\Watcher $watcher |
||
100 | * |
||
101 | * @return string |
||
102 | */ |
||
103 | protected function renderJson(Watcher $watcher) |
||
107 | |||
108 | /** |
||
109 | * Render XML maintenance message. |
||
110 | * |
||
111 | * @param \Janitor\Watcher $watcher |
||
112 | * |
||
113 | * @return string |
||
114 | */ |
||
115 | protected function renderXml(Watcher $watcher) |
||
122 | |||
123 | /** |
||
124 | * Retrieve custom maintenance message. |
||
125 | * |
||
126 | * @param \Janitor\Watcher $watcher |
||
127 | * |
||
128 | * @return string |
||
129 | */ |
||
130 | protected function getMaintenanceMessage(Watcher $watcher) |
||
141 | |||
142 | /** |
||
143 | * Determine content type using Accept header. |
||
144 | * |
||
145 | * @param \Psr\Http\Message\ServerRequestInterface $request |
||
146 | * |
||
147 | * @return string |
||
148 | */ |
||
149 | private function determineContentType(ServerRequestInterface $request) |
||
159 | } |
||
160 |