1 | <?php |
||
19 | class Response |
||
20 | { |
||
21 | /** |
||
22 | * The request method send by the client-browser. |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $requestMethod = null; |
||
27 | |||
28 | /** |
||
29 | * If the response attempts to send any cached headers. |
||
30 | * |
||
31 | * @var bool |
||
32 | */ |
||
33 | protected static $cached = false; |
||
34 | |||
35 | /** |
||
36 | * Type of the data will be send to the client-browser. |
||
37 | * |
||
38 | * @var string |
||
39 | */ |
||
40 | protected static $typed = null; |
||
41 | |||
42 | /** |
||
43 | * @param string $requestMethod |
||
44 | * |
||
45 | * @throws \RuntimeException |
||
46 | */ |
||
47 | public function __construct($requestMethod) |
||
51 | |||
52 | public function asJSON() |
||
59 | |||
60 | public function asHTML() |
||
67 | |||
68 | public function asPDF() |
||
75 | |||
76 | public function asCSV() |
||
83 | |||
84 | public function asTEXT() |
||
91 | |||
92 | public function asZIP() |
||
99 | |||
100 | public function asXZIP() |
||
107 | |||
108 | public function asMSWord() |
||
115 | |||
116 | /** |
||
117 | * Sends a download dialog to the browser. |
||
118 | * |
||
119 | * @param string $stream Can be a file-path or a string. |
||
120 | * @param string $name Name of the stream/file should be shown. |
||
121 | * @param boolean $exit Optional for testing |
||
122 | */ |
||
123 | public function sendStream($stream, $name, $exit = true) |
||
127 | |||
128 | /** |
||
129 | * @param mixed $data |
||
130 | * @param bool $exit |
||
131 | */ |
||
132 | public function send($data, $exit = true) |
||
147 | |||
148 | /** |
||
149 | * If instead you have a page that has personalization on it |
||
150 | * (say, for example, the splash page contains local news as well), |
||
151 | * you can set a copy to be cached only by the browser. |
||
152 | * |
||
153 | * @param int $seconds Interval in seconds |
||
154 | * |
||
155 | * @return $this |
||
156 | */ |
||
157 | public function cacheBrowser($seconds) |
||
165 | |||
166 | /** |
||
167 | * If you want to try as hard as possible to keep a page from being cached anywhere. |
||
168 | * |
||
169 | * @return $this |
||
170 | */ |
||
171 | public function cacheNone() |
||
179 | |||
180 | /** |
||
181 | * If you want to allow a page to be cached by shared proxies for one minute. |
||
182 | * |
||
183 | * @param int $seconds Interval in seconds |
||
184 | * |
||
185 | * @return $this |
||
186 | */ |
||
187 | public function cacheNoValidate($seconds = 60) |
||
195 | |||
196 | /** |
||
197 | * Handles setting pages that are always to be revalidated for freshness by any cache. |
||
198 | * |
||
199 | * @param int $last_modified Timestamp in seconds |
||
200 | * |
||
201 | * @return $this |
||
202 | */ |
||
203 | public function exitIfNotModifiedSince($last_modified) |
||
211 | |||
212 | /** |
||
213 | * @throws \RuntimeException |
||
214 | */ |
||
215 | private function preventMultipleCaching() |
||
225 | } |
||
226 |